コード例 #1
0
 public function __construct()
 {
     $this->validatedProperties = ['exday' => function ($v) {
         $de = new DateTime($v);
         $dn = new DateTime();
         $dd = $dn->diff($de);
         if ($dd->invert == 1) {
             throw new InvalidArgumentException('exday has to be in the future');
         }
         if ($dd->y > 0 || $dd->m > 0 || $dd->d > 21 || $dd->d < 7) {
             throw new InvalidArgumentException('exday has to be at least 7 days in the future but not more than 21 days');
         }
         return $de->format('Y-m-d');
     }, 'ref' => function ($v) {
         if (!is_string($v)) {
             throw new InvalidArgumentException('ref has to be a string');
         }
         if (mb_strlen($v) > 4) {
             throw new InvalidArgumentException('ref must not exceed 4 characters');
         }
         return Sepa::str($v);
     }, 'sid' => function ($v) {
         if (!ctype_digit($v)) {
             throw new InvalidArgumentException('sid has to be digits only');
         }
         if (strlen($v) > 2) {
             throw new InvalidArgumentException('sid must not exceed 2 digits');
         }
         return str_pad($v, 2, '0', STR_PAD_LEFT);
     }, 'opname' => function ($v) {
         if (!is_string($v)) {
             throw new InvalidArgumentException('opname has to be a string');
         }
         if (mb_strlen($v) > 64) {
             throw new InvalidArgumentException('opname must not exceed 64 characters');
         }
         return Sepa::str($v);
     }, 'opiban' => function ($v) {
         if (!IBAN::validate($v)) {
             throw new InvalidArgumentException('invalid iban DExx22');
         }
         return $v;
     }, 'opbic' => function ($v) {
         if (!ctype_alnum($v)) {
             throw new InvalidArgumentException('opbic has to be alphanumeric');
         }
         if (strlen($v) != 11) {
             throw new InvalidArgumentException('opbic has to be 11 characters long');
         }
         return $v;
     }, 'opuid' => function ($v) {
         if (!ctype_alnum($v)) {
             throw new InvalidArgumentException('opbic has to be alphanumeric');
         }
         if (strlen($v) != 18) {
             throw new InvalidArgumentException('opbic has to be 18 characters long');
         }
         return $v;
     }];
 }
コード例 #2
0
 public function __construct()
 {
     $this->validatedProperties = ['TxAmt' => function ($v) {
         if (!is_numeric($v)) {
             throw new InvalidArgumentException('TxAmt has to be numeric');
         }
         if ($v <= 0 || $v >= 500) {
             throw new InvalidArgumentException('0 < TxAmt < 500');
         }
         $r = number_format(round($v, 2), 2, '.', '');
         if ($v != $r) {
             error_log('TxAmt has been rounded');
         }
         return $r;
     }, 'MandatID' => function ($v) {
         if (!is_string($v)) {
             throw new InvalidArgumentException('MandatID has to be a string');
         }
         if (mb_strlen($v) > 20) {
             throw new InvalidArgumentException('MandatID must not exceed 20 characters');
         }
         return Sepa::str($v);
     }, 'MandatSDate' => function ($v) {
         $ds = new DateTime($v);
         $dn = new DateTime();
         $dd = $dn->diff($ds);
         if ($dd->invert == 0) {
             throw new InvalidArgumentException('MandatSDate has to be in the past');
         }
         return $ds->format('Y-m-d');
     }, 'MandatBIC' => function ($v) {
         if (!ctype_alnum($v)) {
             throw new InvalidArgumentException('BIC has to be alphanumeric');
         }
         if (strlen($v) != 11) {
             throw new InvalidArgumentException('BIC has to be 11 characters long');
         }
         return $v;
     }, 'MandatName' => function ($v) {
         if (!is_string($v)) {
             throw new InvalidArgumentException('MandatName has to be a string');
         }
         if (mb_strlen($v) > 64) {
             throw new InvalidArgumentException('MandatName must not exceed 64 characters');
         }
         return Sepa::str($v);
     }, 'MandatIBAN' => function ($v) {
         if (!IBAN::validate($v)) {
             throw new InvalidArgumentException('invalid iban DExx22');
         }
         return $v;
     }, 'MandatInfo' => function ($v) {
         if (!is_string($v)) {
             throw new InvalidArgumentException('MandatInfo has to be a string');
         }
         if (mb_strlen($v) > 128) {
             throw new InvalidArgumentException('MandatInfo must not exceed 128 characters');
         }
         return Sepa::str($v);
     }];
 }