IsoCodes\StructuredCommunication::validate PHP Метод

validate() публичный статический Метод

public static validate ( string $structure ) : boolean
$structure string
Результат boolean
    public static function validate($structure)
    {
        if (12 !== strlen($structure)) {
            return false;
        }
        $sequences = substr($structure, 0, 10);
        $key = substr($structure, -2);
        $control = $sequences % 97;
        // final control must be a 2-digits:
        $control = 1 < strlen($control) ? $control : sprintf('0%d', $control);
        return $key === $control;
    }

Usage Example

 /**
  * testInvalidStructuredCommunication
  *
  * @param mixed $structure
  *
  * @dataProvider getInvalidStructuredCommunication
  *
  * @return void
  */
 public function testInvalidStructuredCommunication($structure)
 {
     $this->assertFalse(StructuredCommunication::validate($structure));
 }
StructuredCommunication