Definition at line 33 of file Isbn.php.
◆ __construct()
__construct |
( |
|
$options = array() | ) |
|
Set up options.
- Parameters
-
- Exceptions
-
- See also
- Zend_Validate_Exception
Definition at line 71 of file Isbn.php.
81 #require_once 'Zend/Validate/Exception.php'; 86 if (array_key_exists(
'type',
$options)) {
91 if (array_key_exists(
'separator',
$options)) {
◆ _detectFormat()
Detect input format.
- Returns
- string
Definition at line 101 of file Isbn.php.
104 $sep = quotemeta($this->_separator);
109 if ($this->_type == self::ISBN10 || $this->_type == self::AUTO) {
114 $pattern =
"/^[0-9]{1,7}[{$sep}]{1}[0-9]{1,7}[{$sep}]{1}[0-9]{1,7}[{$sep}]{1}[0-9X]{1}$/";
123 if ($this->_type == self::ISBN13 || $this->_type == self::AUTO) {
128 $pattern =
"/^[0-9]{1,9}[{$sep}]{1}[0-9]{1,5}[{$sep}]{1}[0-9]{1,9}[{$sep}]{1}[0-9]{1,9}[{$sep}]{1}[0-9]{1}$/";
138 if ((strlen($this->_value) == $lengths[
$pattern]) && preg_match(
$pattern, $this->_value)) {
◆ getSeparator()
Get separator characters.
- Returns
- string
Definition at line 242 of file Isbn.php.
◆ getType()
Get allowed ISBN type.
- Returns
- string
Definition at line 274 of file Isbn.php.
◆ isValid()
Defined by Zend_Validate_Interface.
Returns true if and only if $value is a valid ISBN.
- Parameters
-
- Returns
- boolean
Implements Zend_Validate_Interface.
Definition at line 154 of file Isbn.php.
157 $this->
_error(self::INVALID);
167 $isbn10 = str_replace($this->_separator,
'',
$value);
169 for (
$i = 0;
$i < 9;
$i++) {
170 $sum += (10 -
$i) * $isbn10{
$i};
174 $checksum = 11 - ($sum % 11);
175 if ($checksum == 11) {
177 }
elseif ($checksum == 10) {
184 $isbn13 = str_replace($this->_separator,
'',
$value);
186 for (
$i = 0;
$i < 12;
$i++) {
190 $sum += 3 * $isbn13{
$i};
194 $checksum = 10 - ($sum % 10);
195 if ($checksum == 10) {
201 $this->
_error(self::NO_ISBN);
206 if (substr($this->_value, -1) != $checksum) {
207 $this->
_error(self::NO_ISBN);
elseif(isset( $params[ 'redirect_parent']))
_error($messageKey, $value=null)
◆ setSeparator()
setSeparator |
( |
|
$separator | ) |
|
Set separator characters.
It is allowed only empty string, hyphen and space.
- Parameters
-
- Exceptions
-
- Returns
- Zend_Validate_Isbn Provides a fluent interface
- See also
- Zend_Validate_Exception
Definition at line 222 of file Isbn.php.
225 if (!in_array($separator, array(
'-',
' ',
''))) {
229 #require_once 'Zend/Validate/Exception.php'; 233 $this->_separator = $separator;
◆ setType()
Set allowed ISBN type.
- Parameters
-
- Exceptions
-
- Returns
- Zend_Validate_Isbn Provides a fluent interface
- See also
- Zend_Validate_Exception
Definition at line 254 of file Isbn.php.
257 if (!in_array(
$type, array(self::AUTO, self::ISBN10, self::ISBN13))) {
261 #require_once 'Zend/Validate/Exception.php'; 265 $this->_type =
$type;
◆ $_messageTemplates
Initial value:= array(
self::INVALID => "Invalid type given. String or integer expected",
self::NO_ISBN => "'%value%' is not a valid ISBN number",
)
Definition at line 46 of file Isbn.php.
◆ $_separator
◆ $_type
◆ AUTO
◆ INVALID
const INVALID = 'isbnInvalid' |
◆ ISBN10
◆ ISBN13
◆ NO_ISBN
const NO_ISBN = 'isbnNoIsbn' |
The documentation for this class was generated from the following file:
- vendor/magento/zendframework1/library/Zend/Validate/Isbn.php