update v1.0.7.9 R.C.

This is a Release Candidate. We are still testing.
This commit is contained in:
Sujit Prasad
2016-08-03 20:04:36 +05:30
parent 8b6b924d09
commit ffa56a43cb
3830 changed files with 181529 additions and 495353 deletions

View File

@@ -0,0 +1,61 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zend-validator for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Validator\Isbn;
class Isbn10
{
/**
* @param int|string $value
* @return int|string
*/
public function getChecksum($value)
{
$sum = $this->sum($value);
return $this->checksum($sum);
}
/**
* Calculate the value sum.
*
* @param int|string $value
* @return int
*/
private function sum($value)
{
$sum = 0;
for ($i = 0; $i < 9; $i++) {
$sum += (10 - $i) * $value{$i};
}
return $sum;
}
/**
* Calculate the checksum for the value's sum.
*
* @param int $sum
* @return int|string
*/
private function checksum($sum)
{
$checksum = 11 - ($sum % 11);
if ($checksum == 11) {
return '0';
}
if ($checksum == 10) {
return 'X';
}
return $checksum;
}
}

View File

@@ -0,0 +1,62 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zend-validator for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Validator\Isbn;
class Isbn13
{
/**
* @param int|string $value
* @return int|string
*/
public function getChecksum($value)
{
$sum = $this->sum($value);
return $this->checksum($sum);
}
/**
* Calculate the value sum.
*
* @param int|string $value
* @return int
*/
private function sum($value)
{
$sum = 0;
for ($i = 0; $i < 12; $i++) {
if ($i % 2 == 0) {
$sum += $value{$i};
continue;
}
$sum += 3 * $value{$i};
}
return $sum;
}
/**
* Calculate the checksum for the value's sum.
*
* @param int $sum
* @return int|string
*/
private function checksum($sum)
{
$checksum = 10 - ($sum % 10);
if ($checksum == 10) {
return '0';
}
return $checksum;
}
}