Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
cs278 committed Nov 5, 2010
0 parents commit dca0d1f
Show file tree
Hide file tree
Showing 12 changed files with 710 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License

Copyright (c) 2008 – 2010 Chris Smith

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
6 changes: 6 additions & 0 deletions README.mdwn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
libphp-vin
==========

libphp-vin is a library for PHP to decode [vehicle identification numbers] [1] (VIN).

[1]: http://en.wikipedia.org/wiki/Vehicle_Identification_Number "Vehicle Identification Number"
52 changes: 52 additions & 0 deletions src/libphpvin/CheckDigit/Calculator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* PHP VIN Utility Library
*
* LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @package libphp-vin
* @subpackage CheckDigit\Calculator
* @copyright Copyright (c) 2010 Chris Smith (http://www.cs278.org/)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
* @version
*/
namespace libphpvin\CheckDigit;

/**
* Check digit calculator interface
*
* @package libphp-vin
* @subpackage CheckDigit\Calculator
* @copyright Copyright (c) 2010 Chris Smith (http://www.cs278.org/)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
interface Calculator
{
public function __construct($vin);

public function getVin();

public function setVin($vin);

public function isValid();

public function getCheckDigit();
}
64 changes: 64 additions & 0 deletions src/libphpvin/CheckDigit/Calculator/Abstract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* PHP VIN Utility Library
*
* LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @package libphp-vin
* @subpackage CheckDigit\Calculator
* @copyright Copyright (c) 2010 Chris Smith (http://www.cs278.org/)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
* @version
*/
namespace libphpvin\CheckDigit\Calculator;

/**
* @package libphp-vin
* @subpackage CheckDigit\Calculator
* @copyright Copyright (c) 2010 Chris Smith (http://www.cs278.org/)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
abstract class Abstract implements \libphpvin\CheckDigit\Calculator
{
protected $_vin;

public function __construct($vin)
{
$this->setVin($vin);
}

public function getVin()
{
return $this->_vin;
}

public function setVin($vin)
{
$this->_vin = $vin;

return $this;
}

public function isValid()
{
return $this->getVin()->getCheckDigit() === $this->getCheckDigit();
}
}
52 changes: 52 additions & 0 deletions src/libphpvin/CheckDigit/Calculator/None.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* PHP VIN Utility Library
*
* LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @package libphp-vin
* @subpackage CheckDigit\Calculator
* @copyright Copyright (c) 2010 Chris Smith (http://www.cs278.org/)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
* @version
*/
namespace libphpvin\CheckDigit\Calculator;

/**
* VIN check digit calculator for VINs with no check digit
*
* @package libphp-vin
* @subpackage CheckDigit\Calculator
* @copyright Copyright (c) 2010 Chris Smith (http://www.cs278.org/)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
class None extends Abstract
{
public function isValid()
{
return true;
}

public function getCheckDigit()
{
return '';
}
}
Loading

0 comments on commit dca0d1f

Please sign in to comment.