@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | protected $default; |
31 | 31 | |
32 | - protected $label; |
|
32 | + protected $label; |
|
33 | 33 | |
34 | 34 | protected $rules; |
35 | 35 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | 'required' => false, |
44 | 44 | 'nullable' => false, |
45 | 45 | 'default' => '', |
46 | - 'label' => $name, |
|
46 | + 'label' => $name, |
|
47 | 47 | ]; |
48 | 48 | $rules += $defaults; |
49 | 49 | |
@@ -66,17 +66,17 @@ discard block |
||
66 | 66 | return isset($this->$key) || isset($this->rules[$key]); |
67 | 67 | } |
68 | 68 | |
69 | - public function toArray() { |
|
70 | - return [ |
|
71 | - 'name' => $this->name, |
|
72 | - 'type' => $this->type, |
|
73 | - 'required' => $this->required, |
|
74 | - 'nullable' => $this->nullable, |
|
75 | - 'default' => $this->default, |
|
76 | - 'label' => $this->label, |
|
77 | - 'rules' => $this->rules, |
|
78 | - ]; |
|
79 | - } |
|
69 | + public function toArray() { |
|
70 | + return [ |
|
71 | + 'name' => $this->name, |
|
72 | + 'type' => $this->type, |
|
73 | + 'required' => $this->required, |
|
74 | + 'nullable' => $this->nullable, |
|
75 | + 'default' => $this->default, |
|
76 | + 'label' => $this->label, |
|
77 | + 'rules' => $this->rules, |
|
78 | + ]; |
|
79 | + } |
|
80 | 80 | |
81 | 81 | public function isNumeric() { |
82 | 82 | return in_array($this->type, [ |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | $this->required = $rules['required']; |
336 | 336 | $this->nullable = $rules['nullable']; |
337 | 337 | $this->default = $rules['default']; |
338 | - $this->label = $rules['label']; |
|
338 | + $this->label = $rules['label']; |
|
339 | 339 | |
340 | 340 | unset( |
341 | 341 | $rules['required'], |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $method = $validators[$type]; |
212 | 212 | $clean = Validator::$method($v); |
213 | 213 | } |
214 | - elseif( in_array($type, [Type::OBJECT, Type::ENTITY]) ){ |
|
214 | + elseif( in_array($type, [Type::OBJECT, Type::ENTITY]) ) { |
|
215 | 215 | $clean = Validator::validateObject($v, $this->rules['class'], $this->nullable); |
216 | 216 | } |
217 | 217 | elseif( $type == Type::BINARY ) { |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | $this->required = $rules['required']; |
292 | 292 | $this->nullable = $rules['nullable']; |
293 | 293 | $this->default = $rules['default']; |
294 | - $this->label = $rules['label']; |
|
294 | + $this->label = $rules['label']; |
|
295 | 295 | |
296 | 296 | unset( |
297 | 297 | $rules['required'], |
@@ -211,7 +211,7 @@ |
||
211 | 211 | $method = $validators[$type]; |
212 | 212 | $clean = Validator::$method($v); |
213 | 213 | } |
214 | - elseif( in_array($type, [Type::OBJECT, Type::ENTITY]) ){ |
|
214 | + elseif( in_array($type, [Type::OBJECT, Type::ENTITY]) ) { |
|
215 | 215 | $clean = Validator::validateObject($v, $this->rules['class'], $this->nullable); |
216 | 216 | } |
217 | 217 | elseif( $type == Type::BINARY ) { |
@@ -163,7 +163,7 @@ |
||
163 | 163 | return [$v, Error::REQUIRED]; |
164 | 164 | |
165 | 165 | elseif( !$this->nullable && ($v === null) ) |
166 | - return [$v, Error::NULL]; |
|
166 | + return [$v, Error::null]; |
|
167 | 167 | |
168 | 168 | list($clean, $error) = $this->validateType($v, $this->type); |
169 | 169 |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | new \Twig_SimpleFilter('md5', 'md5'), |
47 | 47 | new \Twig_SimpleFilter('sha1', 'sha1'), |
48 | 48 | new \Twig_SimpleFilter('truncate', function( $str, $length, $replace = '...' ) { |
49 | - if( isset($str) ) |
|
50 | - return strlen($str) <= $length ? $str : substr($str, 0, $length - strip_tags($replace)) . $replace; |
|
51 | - return null; |
|
49 | + if( isset($str) ) |
|
50 | + return strlen($str) <= $length ? $str : substr($str, 0, $length - strip_tags($replace)) . $replace; |
|
51 | + return null; |
|
52 | 52 | }), |
53 | 53 | new \Twig_SimpleFilter('sum', 'array_sum'), |
54 | 54 | new \Twig_SimpleFilter('shuffle', 'shuffle'), |
@@ -76,18 +76,18 @@ discard block |
||
76 | 76 | |
77 | 77 | public function getFunctions() { |
78 | 78 | |
79 | - $functions = [ |
|
80 | - new \Twig_SimpleFunction('ceil', 'ceil'), |
|
81 | - new \Twig_SimpleFunction('floor', 'floor'), |
|
82 | - ]; |
|
79 | + $functions = [ |
|
80 | + new \Twig_SimpleFunction('ceil', 'ceil'), |
|
81 | + new \Twig_SimpleFunction('floor', 'floor'), |
|
82 | + ]; |
|
83 | 83 | |
84 | 84 | // include some helpful shit from yolk-core/StringHelper if we have it available |
85 | - if( class_exists ('\\yolk\\helpers\\StringHelper') ) { |
|
85 | + if( class_exists ('\\yolk\\helpers\\StringHelper') ) { |
|
86 | 86 | $functions = array_merge( |
87 | 87 | $functions, |
88 | 88 | [ |
89 | - new \Twig_SimpleFunction('randomHex', ['\\yolk\\helpers\\StringHelper', 'randomHex']), |
|
90 | - new \Twig_SimpleFunction('randomString', ['\\yolk\\helpers\\StringHelper', 'randomString']), |
|
89 | + new \Twig_SimpleFunction('randomHex', ['\\yolk\\helpers\\StringHelper', 'randomHex']), |
|
90 | + new \Twig_SimpleFunction('randomString', ['\\yolk\\helpers\\StringHelper', 'randomString']), |
|
91 | 91 | ] |
92 | 92 | ); |
93 | 93 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | new \Twig_SimpleFilter('sha1', 'sha1'), |
48 | 48 | new \Twig_SimpleFilter('truncate', function( $str, $length, $replace = '...' ) { |
49 | 49 | if( isset($str) ) |
50 | - return strlen($str) <= $length ? $str : substr($str, 0, $length - strip_tags($replace)) . $replace; |
|
50 | + return strlen($str) <= $length ? $str : substr($str, 0, $length - strip_tags($replace)).$replace; |
|
51 | 51 | return null; |
52 | 52 | }), |
53 | 53 | new \Twig_SimpleFilter('sum', 'array_sum'), |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | ]; |
56 | 56 | |
57 | 57 | // include some helpful shit from yolk-core/StringHelper if we have it available |
58 | - if( class_exists ('\\yolk\\helpers\\StringHelper') ) { |
|
58 | + if( class_exists('\\yolk\\helpers\\StringHelper') ) { |
|
59 | 59 | $filters = array_merge( |
60 | 60 | $filters, |
61 | 61 | [ |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | // more helpful shit from yolk-core/Inflector if we have it available |
74 | - if( class_exists ('\\yolk\\helpers\\Inflector') ) { |
|
74 | + if( class_exists('\\yolk\\helpers\\Inflector') ) { |
|
75 | 75 | $filters = array_merge( |
76 | 76 | $filters, |
77 | 77 | [ |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | ]; |
94 | 94 | |
95 | 95 | // include some helpful shit from yolk-core/StringHelper if we have it available |
96 | - if( class_exists ('\\yolk\\helpers\\StringHelper') ) { |
|
96 | + if( class_exists('\\yolk\\helpers\\StringHelper') ) { |
|
97 | 97 | $functions = array_merge( |
98 | 98 | $functions, |
99 | 99 | [ |
@@ -40,7 +40,7 @@ |
||
40 | 40 | */ |
41 | 41 | public function add( $name, $type = Type::TEXT, $rules = [] ) { |
42 | 42 | $this->fields[$name] = new Field($name, $type, $rules); |
43 | - $this->types = []; // clear this so it will be refreshed when we've finished adding fields |
|
43 | + $this->types = []; // clear this so it will be refreshed when we've finished adding fields |
|
44 | 44 | return $this; |
45 | 45 | } |
46 | 46 |
@@ -11,16 +11,16 @@ |
||
11 | 11 | |
12 | 12 | namespace yolk\support\Exceptions; |
13 | 13 | |
14 | -class ValidationException extends \DomainException { |
|
14 | +class ValidationException extends \DomainException { |
|
15 | 15 | |
16 | 16 | protected $errors = []; |
17 | 17 | |
18 | - public function __construct( array $errors, $source, \Exception $previous = null ) { |
|
18 | + public function __construct( array $errors, $source, \Exception $previous = null ) { |
|
19 | 19 | parent::__construct("Validation Error: {$source}"); |
20 | 20 | $this->errors = $errors; |
21 | 21 | } |
22 | 22 | |
23 | - public function getErrors() { |
|
23 | + public function getErrors() { |
|
24 | 24 | return $this->errors; |
25 | 25 | } |
26 | 26 |
@@ -42,7 +42,7 @@ |
||
42 | 42 | if( !isset($config) || !is_array($config) ) |
43 | 43 | throw new \LogicException('Invalid Configuration'); |
44 | 44 | |
45 | - if( empty($key) ) |
|
45 | + if( empty($key) ) |
|
46 | 46 | $this->merge($config); |
47 | 47 | else |
48 | 48 | $this->set($key, $config); |
@@ -225,7 +225,7 @@ |
||
225 | 225 | * @param integer $limit |
226 | 226 | * @return self |
227 | 227 | */ |
228 | - public function limit( $limit ) { |
|
228 | + public function limit( $limit ) { |
|
229 | 229 | $this->limit = max(1, (int) $limit); |
230 | 230 | return $this; |
231 | 231 | } |
@@ -225,7 +225,7 @@ |
||
225 | 225 | * @param integer $limit |
226 | 226 | * @return self |
227 | 227 | */ |
228 | - public function limit( $limit ) { |
|
228 | + public function limit( $limit ) { |
|
229 | 229 | $this->limit = max(1, (int) $limit); |
230 | 230 | return $this; |
231 | 231 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | */ |
27 | 27 | public static function __callStatic( $name, $args ) { |
28 | 28 | |
29 | - $name = 'validate'. substr($name, 2); |
|
29 | + $name = 'validate'.substr($name, 2); |
|
30 | 30 | |
31 | 31 | if( !method_exists(__CLASS__, $name) ) |
32 | 32 | throw new \BadMethodCallException(sprintf("%s::%s()", get_called_class(), $name)); |