@@ -37,7 +37,7 @@ |
||
| 37 | 37 | $options = explode(':', $validation); |
| 38 | 38 | $validationName = array_shift($options); |
| 39 | 39 | if (!array_key_exists($validationName, $this->map)) { |
| 40 | - throw new InvalidValidationNameException('unknown validation name ' . $validationName); |
|
| 40 | + throw new InvalidValidationNameException('unknown validation name '.$validationName); |
|
| 41 | 41 | } |
| 42 | 42 | return new $this->map[$validationName]($options); |
| 43 | 43 | } |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | |
| 33 | 33 | public function setType($type) |
| 34 | 34 | { |
| 35 | - if (!in_array($type, $this->types())) throw new ValueObjectInvalidTypeException('Wrong type: ' . $type); |
|
| 35 | + if (!in_array($type, $this->types())) throw new ValueObjectInvalidTypeException('Wrong type: '.$type); |
|
| 36 | 36 | $this->type = $type; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -17,8 +17,8 @@ |
||
| 17 | 17 | return $valueTime < $targetTime; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - protected function getDateForCompare(){ |
|
| 21 | - if(isset($this->options[0]) ) return $this->options[0]; |
|
| 20 | + protected function getDateForCompare() { |
|
| 21 | + if (isset($this->options[0])) return $this->options[0]; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public function errorMessage() |
@@ -11,8 +11,8 @@ discard block |
||
| 11 | 11 | { |
| 12 | 12 | public function isValid(ValueObject $data) |
| 13 | 13 | { |
| 14 | - if( ! is_string($data->value()) ) return false; |
|
| 15 | - if(isset($this->options[0])){ |
|
| 14 | + if (!is_string($data->value())) return false; |
|
| 15 | + if (isset($this->options[0])) { |
|
| 16 | 16 | $dateObj = DateTime::createFromFormat($this->options[0], $data->value()); |
| 17 | 17 | return $dateObj && $dateObj->format($this->options[0]) === $data->value(); |
| 18 | 18 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public function errorMessage() |
| 29 | 29 | { |
| 30 | - if(isset($this->options[0])) return "{$this->data->name()} is not in date format {$this->options[0]}"; |
|
| 30 | + if (isset($this->options[0])) return "{$this->data->name()} is not in date format {$this->options[0]}"; |
|
| 31 | 31 | |
| 32 | 32 | return "{$this->data->name()} must be a valid date"; |
| 33 | 33 | } |
@@ -16,8 +16,8 @@ |
||
| 16 | 16 | return $valueTime > $targetTime; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - protected function getDateForCompare(){ |
|
| 20 | - if(isset($this->options[0]) ) return $this->options[0]; |
|
| 19 | + protected function getDateForCompare() { |
|
| 20 | + if (isset($this->options[0])) return $this->options[0]; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | protected function errorMessage() |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | $targetStartTime = strtotime($this->options[0]); |
| 15 | 15 | $targetEndTime = strtotime($this->options[1]); |
| 16 | 16 | |
| 17 | - return ( $valueTime > $targetStartTime ) && ( $valueTime < $targetEndTime); |
|
| 17 | + return ($valueTime > $targetStartTime) && ($valueTime < $targetEndTime); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public function errorMessage() |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | |
| 20 | 20 | public function __construct($options = null) |
| 21 | 21 | { |
| 22 | - if(!is_null($options) && !is_array($options) ) $options = [$options]; |
|
| 22 | + if (!is_null($options) && !is_array($options)) $options = [$options]; |
|
| 23 | 23 | $this->options = $options; |
| 24 | 24 | } |
| 25 | 25 | |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | |
| 16 | 16 | protected function errorMessage() |
| 17 | 17 | { |
| 18 | - return "{$this->data->name()} is not in (" . print_r($this->options[0],true) .")"; |
|
| 18 | + return "{$this->data->name()} is not in (".print_r($this->options[0], true).")"; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | \ No newline at end of file |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | $validation = $validationFactory->get($key); |
| 30 | 30 | $validation->setErrorMessage($val); |
| 31 | 31 | } else { |
| 32 | - if($this->isCachedValidation($val)){ |
|
| 32 | + if ($this->isCachedValidation($val)) { |
|
| 33 | 33 | $validation = $this->validationCache[$val]; |
| 34 | 34 | } else { |
| 35 | 35 | $validation = $validationFactory->get($val); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | return $signatures; |
| 71 | - } elseif ($options instanceof AbstractValidation){ |
|
| 71 | + } elseif ($options instanceof AbstractValidation) { |
|
| 72 | 72 | return [$this->addToCache($options)]; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | return array_unique($this->errors); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - protected function addToCache(AbstractValidation $validation){ |
|
| 162 | - $key = '__cache__' . sizeof($this->validationCache); |
|
| 161 | + protected function addToCache(AbstractValidation $validation) { |
|
| 162 | + $key = '__cache__'.sizeof($this->validationCache); |
|
| 163 | 163 | $this->validationCache[$key] = $validation; |
| 164 | 164 | return $key; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - protected function isCachedValidation($name){ |
|
| 167 | + protected function isCachedValidation($name) { |
|
| 168 | 168 | return array_key_exists($name, $this->validationCache); |
| 169 | 169 | } |
| 170 | 170 | |