joelwalls/picoyplaca

此简单包根据基多市的限制,预测给定车牌号在特定日期和时间是否可以上路。

v1.0.2 2020-04-22 15:26 UTC

This package is auto-updated.

Last update: 2024-09-23 02:19:14 UTC


README

Latest Version Software License Build Status Total Downloads

此小型包提供了一种简单的类,用于根据基多市交通规则的时间限制预测某个车牌号是否可以在路上行驶。框架无关。

安装

通过Composer

$ composer require joelwalls/picoyplaca

用法

类的简单用法

require_once "vendor/autoload.php";

$predictor = new JoelWalls\PicoYPlaca\Predictor($license_plate, $date, $time);

if ($predictor->canDrive()) {
    echo "Car can be on the road";
} else {
    echo "Car cannnot be on the road";
}

该包支持DateTime实例作为第二个参数。

require_once "vendor/autoload.php";

use JoelWalls\PicoYPlaca\Predictor;

$predictor = new Predictor($license_plate, new \DateTime);

if ($predictor->canDrive()) {
    echo "Car can be on the road";
} else {
    echo "Car cannnot be on the road";
}

如果需要,您还可以指定Predictor对象的时区,以防服务器使用不同的时区。

require_once "vendor/autoload.php";

use JoelWalls\PicoYPlaca\Predictor;

$predictor = new Predictor($license_plate, new \DateTime);
$predictor->setTimeZone('America/Guayaquil');

if ($predictor->canDrive()) {
    echo "Car can be on the road";
} else {
    echo "Car cannnot be on the road";
}

注意:当Predictor在初始化时使用DateTime对象作为当前时间时,建议使用setTimeZone()方法。

测试

$ phpunit

致谢

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件