Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
5 / 5 |
Ipv6 | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
5 / 5 |
evaluate | |
100.00% |
1 / 1 |
3 | |
100.00% |
5 / 5 |
<?php | |
/** | |
* Pop PHP Framework (http://www.popphp.org/) | |
* | |
* @link https://github.com/popphp/popphp-framework | |
* @author Nick Sagona, III <dev@nolainteractive.com> | |
* @copyright Copyright (c) 2009-2019 NOLA Interactive, LLC. (http://www.nolainteractive.com) | |
* @license http://www.popphp.org/license New BSD License | |
*/ | |
/** | |
* @namespace | |
*/ | |
namespace Pop\Validator; | |
/** | |
* IPv6 validator class | |
* | |
* @category Pop | |
* @package Pop\Validator | |
* @author Nick Sagona, III <dev@nolainteractive.com> | |
* @copyright Copyright (c) 2009-2019 NOLA Interactive, LLC. (http://www.nolainteractive.com) | |
* @license http://www.popphp.org/license New BSD License | |
* @version 3.0.2 | |
*/ | |
class Ipv6 extends AbstractValidator | |
{ | |
/** | |
* Method to evaluate the validator | |
* | |
* @param mixed $input | |
* @return boolean | |
*/ | |
public function evaluate($input = null) | |
{ | |
// Set the input, if passed | |
if (null !== $input) { | |
$this->input = $input; | |
} | |
// Set the default message | |
if (null === $this->message) { | |
$this->message = 'The value must be a valid IPv6 address.'; | |
} | |
return (bool)(preg_match('/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1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