@@ -18,12 +18,12 @@ |
||
| 18 | 18 | public function validate($value) |
| 19 | 19 | { |
| 20 | 20 | if (!is_string($value)) { |
| 21 | - return new NoString([ 'type' => 'set' ]); |
|
| 21 | + return new NoString(['type' => 'set']); |
|
| 22 | 22 | } else { |
| 23 | 23 | $values = explode(',', $value); |
| 24 | 24 | foreach ($values as $value) { |
| 25 | 25 | if (!in_array($value, $this->allowedValues)) { |
| 26 | - return new NotAllowed([ 'value' => $value, 'type' => 'set' ]); |
|
| 26 | + return new NotAllowed(['value' => $value, 'type' => 'set']); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | return new Error([], 'DATETIME', 'DateTime is not allowed for time'); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - return new NoTime([ 'value' => (string)$value ]); |
|
| 29 | + return new NoTime(['value' => (string) $value]); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | return true; |
@@ -32,10 +32,9 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function __construct($precision = null, $dateOnly = false) |
| 34 | 34 | { |
| 35 | - $this->precision = (int)$precision; |
|
| 35 | + $this->precision = (int) $precision; |
|
| 36 | 36 | $this->regex = $dateOnly ? |
| 37 | - '/^' . self::DATE_REGEX . '([ T]' . self::TIME_REGEX . self::ZONE_REGEX . ')?$/' : |
|
| 38 | - '/^' . self::DATE_REGEX . '[ T]' . self::TIME_REGEX . self::ZONE_REGEX . '$/'; |
|
| 37 | + '/^' . self::DATE_REGEX . '([ T]' . self::TIME_REGEX . self::ZONE_REGEX . ')?$/' : '/^' . self::DATE_REGEX . '[ T]' . self::TIME_REGEX . self::ZONE_REGEX . '$/'; |
|
| 39 | 38 | } |
| 40 | 39 | |
| 41 | 40 | public static function factory(Dbal $dbal, array $columnDefinition) |
@@ -49,7 +48,7 @@ discard block |
||
| 49 | 48 | public function validate($value) |
| 50 | 49 | { |
| 51 | 50 | if (!$value instanceof \DateTime && (!is_string($value) || !preg_match($this->regex, $value))) { |
| 52 | - return new NoDateTime([ 'value' => (string)$value ]); |
|
| 51 | + return new NoDateTime(['value' => (string) $value]); |
|
| 53 | 52 | } |
| 54 | 53 | |
| 55 | 54 | return true; |
@@ -41,9 +41,9 @@ |
||
| 41 | 41 | public function validate($value) |
| 42 | 42 | { |
| 43 | 43 | if (!is_string($value)) { |
| 44 | - return new NoString([ 'type' => 'enum' ]); |
|
| 44 | + return new NoString(['type' => 'enum']); |
|
| 45 | 45 | } elseif (!in_array($value, $this->allowedValues)) { |
| 46 | - return new NotAllowed([ 'value' => $value, 'type' => 'enum' ]); |
|
| 46 | + return new NotAllowed(['value' => $value, 'type' => 'enum']); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | return true; |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function __construct($maxLength = null) |
| 32 | 32 | { |
| 33 | - $this->maxLength = (int)$maxLength; |
|
| 33 | + $this->maxLength = (int) $maxLength; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public static function factory(Dbal $dbal, array $columnDefinition) |
@@ -41,9 +41,9 @@ discard block |
||
| 41 | 41 | public function validate($value) |
| 42 | 42 | { |
| 43 | 43 | if (!is_string($value)) { |
| 44 | - return new NoString([ 'type' => $this->type ]); |
|
| 44 | + return new NoString(['type' => $this->type]); |
|
| 45 | 45 | } elseif ($this->maxLength !== 0 && mb_strlen($value) > $this->maxLength) { |
| 46 | - return new TooLong([ 'value' => $value, 'max' => $this->maxLength ]); |
|
| 46 | + return new TooLong(['value' => $value, 'max' => $this->maxLength]); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | return true; |
@@ -44,14 +44,14 @@ |
||
| 44 | 44 | if (!is_bool($value)) { |
| 45 | 45 | // convert int to string |
| 46 | 46 | if (is_int($value)) { |
| 47 | - $value = (string)$value; |
|
| 47 | + $value = (string) $value; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | if (!is_string($value) || |
| 51 | 51 | ($value !== $this->getBoolean(true) && $value !== $this->getBoolean(false)) |
| 52 | 52 | ) { |
| 53 | 53 | // value is not boolean, not int and (not string OR string value for boolean) |
| 54 | - return new NoBoolean([ 'value' => (string)$value ]); |
|
| 54 | + return new NoBoolean(['value' => (string) $value]); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | public function validate($value) |
| 17 | 17 | { |
| 18 | 18 | if (!is_int($value) && !is_double($value) && (!is_string($value) || !is_numeric($value))) { |
| 19 | - return new NoNumber([ 'value' => (string)$value ]); |
|
| 19 | + return new NoNumber(['value' => (string) $value]); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | return true; |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | public function validate($value) |
| 18 | 18 | { |
| 19 | 19 | if (!is_string($value) || $value !== 'null' && json_decode($value) === null) { |
| 20 | - return new InvalidJson([ 'value' => (string)$value ]); |
|
| 20 | + return new InvalidJson(['value' => (string) $value]); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | return true; |