amattu2/nhtsa-wrapper 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

amattu2/nhtsa-wrapper

Composer 安装命令:

composer require amattu2/nhtsa-wrapper

包简介

A simple PHP based NHTSA (U.S. Department of Transportation) vehicle VIN decoder and Recall lookup API wrapper.

README 文档

README

This is a simple VIN decoder wrapper for the NHTSA (United States Department of Transportation) VIN decoder API. Additionally, it includes the NHTSA vehicle recall API. See usage section below or the example index.php file.

Usage

Import

Install with composer

require amattu2/nhtsa-wrapper
require "vendor/autoload.php";

VIN Decode

Raw Decode

PHPDoc

/**
 * Decode a 17-digit VIN
 *
 * @param string vin number
 * @param ?integer model year
 * @return ?array raw NHTSA result
 * @throws TypeError
 * @author Alec M. <https://amattu.com>
 * @date 2021-04-04T16:19:40-040
 */

Usage

$decode = amattu2\NHTSA\Client::decodeVIN("VIN_NUMBER");

Success return result

Array
(
  [Error Text] =>
  [Make] =>
  [Manufacturer Name] =>
  [Model] =>
  [Model Year] =>
  [Plant City] =>
  [Series] =>
  [Trim] =>
  [Vehicle Type] =>
  [Plant Country] =>
  ...
)

Pretty Decode

PHPDoc

/**
* Parse a raw decode call
* Converts a decodeVIN call into a pretty parsed Year, Make, Model, Trim, Engine array
*
* @param array raw decode result
* @return ?array pretty parsed NHTSA result
* @throws TypeError
* @author Alec M. <https://amattu.com>
* @date 2021-04-04T16:52:15-040
*/

Usage

$decode = amattu2\NHTSA\Client::decodeVIN("VIN_NUMBER");
$pretty_decode = amattu2\NHTSA\Client::parseDecode($decode);

Success return result (Example)

Array
(
  [Model_Year] => 2011
  [Make] => MERCEDES-BENZ
  [Model] => M-CLASS
  [Trim] =>  4-MATIC
  [Engine] => 3.5L 6-CYL (3,500CC)
)

Recalls

Raw Recalls

PHPDoc

/**
 * Get vehicle recalls by Year, Make, Model
 *
 * @param int model year
 * @param string make
 * @param string model
 * @return ?array NHTSA raw result
 * @throws TypeError
 * @author Alec M. <https://amattu.com>
 * @date 2021-04-04T16:48:24-040
 */

Usage

$recalls = amattu2\NHTSA\Client::getRecalls(2015, "Ford", "Mustang");

Success return result

Array
(
  [0] => Array
  (
      [Manufacturer] =>
      [NHTSACampaignNumber] =>
      [ReportReceivedDate] =>
      [Component] =>
      [Summary] =>
      [Conequence] =>
      [Remedy] =>
      [Notes] =>
      [ModelYear] =>
      [Make] =>
      [Model] =>
  )
  ...
)

Pretty Recalls

PHPDoc

/**
 * Parse a raw recall result
 *
 * @param array raw recall result
 * @return ?array parsed recall result
 * @throws TypeError
 * @author Alec M. <https://amattu.com>
 * @date 2021-04-04T18:16:26-040
*/

Usage

$recalls = amattu2\NHTSA\Client::getRecalls(2015, "Ford", "Mustang");
$pretty_recalls = amattu2\NHTSA\Client::parseRecalls($recalls);

Success return result

Array
(
  [2] => Array
  (
    [Campaign_Number] =>
    [Component] => Array
    (
      [0] => FUEL SYSTEM, GASOLINE
      [1] => STORAGE
      [2] => TANK ASSEMBLY /* The last element is the actual component */
    )
    [Date] => 2015-06-02
    [Description] =>
    [Remedy] =>
  )
  ...
)

getModelsForMakeByYear

PHPDoc

/**
 * Get all available models for a make by year
 *
 * @note This is a free-text match. Recommend using `getModelsForMakeIdByYear`
 * @param int $year The model year
 * @param string $make The make
 */

Usage

$models = amattu2\NHTSA\Client::getModelsForMakeByYear(2015, "Ford");

Success return result

Array
(
  [0] => Array
  (
    [Make_ID] => 441
    [Make_Name] => FORD
    [Model_ID] => 2021
    [Model_Name] => C-MAX
  )
  ...
)

getModelsForMakeIdByYear

PHPDoc

/**
 * Get all available models for a make by year
 *
 * @param int $year The model year
 * @param int $make_id The make ID
 */

Usage

$models = amattu2\NHTSA\Client::getModelsForMakeIdByYear(2015, 441);

Success return result

Array
(
  [0] => Array
  (
    [Make_ID] => 441
    [Make_Name] => FORD
    [Model_ID] => 2021
    [Model_Name] => C-MAX
  )
  ...
)

getModelsForMake

PHPDoc

/**
 * Get all available models for a make
 *
 * @param string $make The make
 */

Usage

$models = amattu2\NHTSA\Client::getModelsForMake("Ford");

Success return result

Array
(
  [0] => Array
  (
    [Make_ID] => 441
    [Make_Name] => FORD
    [Model_ID] => 2021
    [Model_Name] => C-MAX
  )
  ...
)

getModelsForMakeId

PHPDoc

/**
 * Get all available models for a make
 *
 * @param int $make_id The make ID
 */

Usage

$models = amattu2\NHTSA\Client::getModelsForMakeId(441);

Success return result

Array
(
  [0] => Array
  (
    [Make_ID] => 441
    [Make_Name] => FORD
    [Model_ID] => 2021
    [Model_Name] => C-MAX
  )
  ...
)

Requirements & Dependencies

  • PHP 7.4+
  • cURL Extension

amattu2/nhtsa-wrapper 适用场景与选型建议

amattu2/nhtsa-wrapper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 563 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 03 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 amattu2/nhtsa-wrapper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 amattu2/nhtsa-wrapper 我们能提供哪些服务?
定制开发 / 二次开发

基于 amattu2/nhtsa-wrapper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 563
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 37
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: AGPL-3.0
  • 更新时间: 2023-03-09