gan4x4 / tyresize
轮胎尺寸解析器
dev-master
2017-09-07 20:53 UTC
Requires
- php: >=5.4.4
Requires (Dev)
- phpunit/phpunit: ~5.0
This package is auto-updated.
Last update: 2024-09-29 04:42:41 UTC
README
相同尺寸的轮胎可能会有不同的标记。最著名的是美国(英寸 31x10.5R16)和欧洲(公制)。
英寸尺寸指定轮胎的高度和宽度以及轮辋的英寸尺寸。例如 31x10.5R16。
在第二种情况下,标记包括毫米单位的宽度,轮胎胎面高度占轮辋尺寸的百分比: 265/75R16
此外,一些制造商以特殊方式标记轻型卡车、卡车和充气轮胎。例如,在Interco公司,某些轮胎的宽度和高度被颠倒(Bogger轮胎B-119的 16x35-16 而不是 35x16-16)。许多充气轮圈用公制单位标记,但不标明胎面: 1300x700-24 一些轮胎没有包含标记尺寸的明确信息,例如 Q78-15 或 160m。
这个库可以帮助处理这种多样的标记。它可以用来创建轮胎计算器或搜索轮胎数据库。
安装
可以使用Composer安装轮胎尺寸解析器。运行以下命令
composer require gan4x4/tyresize
用法
<?php /* * Example of tyresize library usage */ require_once("../vendor/autoload.php"); use gan4x4\Market\Size\TyreSize; use gan4x4\Market\Size\InvalidTyreSizeException; try{ // Call factory method that return instance of TyreSize descendant. // Class of returned object depends of what type of tyre marking $firstTyre = TyreSize::parseSize("36x12.5-16"); // Instance print "Size parsed! \n"; print "This tyre width is ".$firstTyre->getMetricWidth()."mm \n"; //This tyre width is 320mm print "this tyre has profile ". $firstTyre->getProfile()."%\n"; //this tyre has profile 80% print "this tyre full metric name is ".$firstTyre->getMetricName()."\n"; //this tyre full metric name is 320/80-16 print "Value of 4 tyre is ".($firstTyre->getValue()*4)." m3 \n"; //Value of 4 tyre is 1.161288 m3 print "\nCompare tyres\n"; $secondTyre = TyreSize::parseSize("375/65R16"); if ($firstTyre->getInchHeigth() > $secondTyre->getInchHeigth()){ print $firstTyre->getOriginal()." is bigger than ".$secondTyre->getOriginal()."\n"; } // 36x12.5-16 is bigger than 375/65R16 if ($firstTyre->getInchWidth() < $secondTyre->getInchWidth()){ print "But ". $secondTyre->getOriginal()." is more fat than ".$firstTyre->getOriginal()."\n"; } // But 375/65R16 is more fat than 36x12.5-16 print "\nYou can use some rare marks\n"; $q78 = TyreSize::parseSize("Q78-15"); print $q78->getOriginal()." is equal to ".$q78->getInchName()."\n"; $fullProfileTyre = TyreSize::parseSize("195R16"); // Q78-15 is equal to 35.5x11-15 print $fullProfileTyre->getOriginal()." is equal to ".$fullProfileTyre->getMetricName()."\n"; // 195R16 is equal to 195/80R16 } catch (InvalidTyreSizeException $ex) { print "Invalid tyre size"; }