@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace WFV\Validators; |
| 3 | -defined( 'ABSPATH' ) || die(); |
|
| 3 | +defined('ABSPATH') || die(); |
|
| 4 | 4 | |
| 5 | 5 | use WFV\Validators\AbstractValidator; |
| 6 | 6 | |
@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | * @param bool (optional) $optional |
| 33 | 33 | * @return bool |
| 34 | 34 | */ |
| 35 | - public function validate( $input = null, $optional = false ) { |
|
| 35 | + public function validate($input = null, $optional = false) { |
|
| 36 | 36 | $args = func_get_args(); |
| 37 | 37 | $params = $args[2]; |
| 38 | 38 | $max_value = $params[0]; |
| 39 | 39 | |
| 40 | 40 | $v = $this->validator->create(); |
| 41 | - return ( $optional ) |
|
| 42 | - ? $v->optional( $v->create()->length( null, $max_value ) )->validate( $input ) |
|
| 43 | - : $v->length( null, $max_value )->validate( $input ); |
|
| 41 | + return ($optional) |
|
| 42 | + ? $v->optional($v->create()->length(null, $max_value))->validate($input) |
|
| 43 | + : $v->length(null, $max_value)->validate($input); |
|
| 44 | 44 | } |
| 45 | 45 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace WFV\Validators; |
| 3 | -defined( 'ABSPATH' ) or die(); |
|
| 3 | +defined('ABSPATH') or die(); |
|
| 4 | 4 | |
| 5 | 5 | use WFV\Validators\AbstractValidator; |
| 6 | 6 | |
@@ -32,18 +32,18 @@ discard block |
||
| 32 | 32 | * @param bool (optional) $optional |
| 33 | 33 | * @return bool |
| 34 | 34 | */ |
| 35 | - public function validate( $input = null, $optional = false ){ |
|
| 35 | + public function validate($input = null, $optional = false) { |
|
| 36 | 36 | $args = func_get_args(); |
| 37 | 37 | $params = $args[2]; |
| 38 | 38 | $other_field = $params[0]; |
| 39 | 39 | |
| 40 | 40 | $v = $this->validator->create(); |
| 41 | 41 | |
| 42 | - if( $optional ) { |
|
| 42 | + if ($optional) { |
|
| 43 | 43 | return $v->optional( |
| 44 | - $v->create()->not( $v->create()->equals( $_POST[ $other_field ] )) ) |
|
| 45 | - ->validate( $input ); |
|
| 44 | + $v->create()->not($v->create()->equals($_POST[$other_field])) ) |
|
| 45 | + ->validate($input); |
|
| 46 | 46 | } |
| 47 | - return $v->not( $v->create()->equals( $_POST[ $other_field ] ))->validate( $input ); |
|
| 47 | + return $v->not($v->create()->equals($_POST[$other_field]))->validate($input); |
|
| 48 | 48 | } |
| 49 | 49 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace WFV\Validators; |
| 3 | -defined( 'ABSPATH' ) || die(); |
|
| 3 | +defined('ABSPATH') || die(); |
|
| 4 | 4 | |
| 5 | 5 | use WFV\Validators\AbstractValidator; |
| 6 | 6 | |
@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | * @param bool (optional) $optional |
| 33 | 33 | * @return bool |
| 34 | 34 | */ |
| 35 | - public function validate( $input = null, $optional = false ) { |
|
| 35 | + public function validate($input = null, $optional = false) { |
|
| 36 | 36 | $args = func_get_args(); |
| 37 | 37 | $params = $args[2]; |
| 38 | 38 | $min_value = $params[0]; |
| 39 | 39 | |
| 40 | 40 | $v = $this->validator->create(); |
| 41 | - return ( $optional ) |
|
| 42 | - ? $v->optional( $v->create()->length( $min_value, null ) )->validate( $input ) |
|
| 43 | - : $v->length( $min_value, null )->validate( $input ); |
|
| 41 | + return ($optional) |
|
| 42 | + ? $v->optional($v->create()->length($min_value, null))->validate($input) |
|
| 43 | + : $v->length($min_value, null)->validate($input); |
|
| 44 | 44 | } |
| 45 | 45 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace WFV\Validators; |
| 3 | -defined( 'ABSPATH' ) || die(); |
|
| 3 | +defined('ABSPATH') || die(); |
|
| 4 | 4 | |
| 5 | 5 | use WFV\Validators\AbstractValidator; |
| 6 | 6 | |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | * @param bool (optional) $optional |
| 33 | 33 | * @return bool |
| 34 | 34 | */ |
| 35 | - public function validate( $input = null, $optional = false ) { |
|
| 35 | + public function validate($input = null, $optional = false) { |
|
| 36 | 36 | $v = $this->validator->create(); |
| 37 | - return ( $optional ) |
|
| 38 | - ? $v->optional( $v->create()->url() )->validate( $input ) |
|
| 39 | - : $v->url()->validate( $input ); |
|
| 37 | + return ($optional) |
|
| 38 | + ? $v->optional($v->create()->url())->validate($input) |
|
| 39 | + : $v->url()->validate($input); |
|
| 40 | 40 | } |
| 41 | 41 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace WFV\Validators; |
| 3 | -defined( 'ABSPATH' ) || die(); |
|
| 3 | +defined('ABSPATH') || die(); |
|
| 4 | 4 | |
| 5 | 5 | use WFV\Validators\AbstractValidator; |
| 6 | 6 | |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | * @param bool (optional) $optional |
| 33 | 33 | * @return bool |
| 34 | 34 | */ |
| 35 | - public function validate( $input = null, $optional = false ) { |
|
| 35 | + public function validate($input = null, $optional = false) { |
|
| 36 | 36 | $v = $this->validator->create(); |
| 37 | - return ( $optional ) |
|
| 38 | - ? $v->optional( $v->create()->phone() )->validate( $input ) |
|
| 39 | - : $v->phone()->validate( $input ); |
|
| 37 | + return ($optional) |
|
| 38 | + ? $v->optional($v->create()->phone())->validate($input) |
|
| 39 | + : $v->phone()->validate($input); |
|
| 40 | 40 | } |
| 41 | 41 | } |
@@ -26,7 +26,6 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @since 0.10.0 |
| 28 | 28 | * |
| 29 | - * @param array $data |
|
| 30 | 29 | * @param bool $trim |
| 31 | 30 | */ |
| 32 | 31 | public function __construct( InspectionAgent $guard, $trim = true ) { |
@@ -67,6 +66,7 @@ discard block |
||
| 67 | 66 | * @since 0.11.0 |
| 68 | 67 | * @access protected |
| 69 | 68 | * |
| 69 | + * @param boolean $trim |
|
| 70 | 70 | */ |
| 71 | 71 | protected function populate( $trim ) { |
| 72 | 72 | if( $this->guard->safe_submit() ) { |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace WFV\Collection; |
| 3 | -defined( 'ABSPATH' ) || die(); |
|
| 3 | +defined('ABSPATH') || die(); |
|
| 4 | 4 | |
| 5 | 5 | use WFV\Abstraction\Collectable; |
| 6 | 6 | use WFV\Agent\InspectionAgent; |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | * @param array $data |
| 30 | 30 | * @param bool $trim |
| 31 | 31 | */ |
| 32 | - public function __construct( InspectionAgent $guard, $trim = true ) { |
|
| 32 | + public function __construct(InspectionAgent $guard, $trim = true) { |
|
| 33 | 33 | $this->guard = $guard; |
| 34 | - $this->populate( $trim ); |
|
| 34 | + $this->populate($trim); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * @param bool $neat With or without token and action attributes. |
| 43 | 43 | * @return array |
| 44 | 44 | */ |
| 45 | - public function get_array( $neat = true ) { |
|
| 46 | - return ( $neat ) ? $this->neat_array() : $this->data; |
|
| 45 | + public function get_array($neat = true) { |
|
| 46 | + return ($neat) ? $this->neat_array() : $this->data; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | protected function neat_array() { |
| 58 | 58 | $input = $this->data; |
| 59 | - unset( $input[ $input['action'] .'_token'] ); |
|
| 60 | - unset( $input['action'] ); |
|
| 59 | + unset($input[$input['action'].'_token']); |
|
| 60 | + unset($input['action']); |
|
| 61 | 61 | return $input; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | * @access protected |
| 69 | 69 | * |
| 70 | 70 | */ |
| 71 | - protected function populate( $trim ) { |
|
| 72 | - if( $this->guard->safe_submit() ) { |
|
| 73 | - $data = $this->transform_array_leafs( $_POST, 'stripslashes' ); |
|
| 71 | + protected function populate($trim) { |
|
| 72 | + if ($this->guard->safe_submit()) { |
|
| 73 | + $data = $this->transform_array_leafs($_POST, 'stripslashes'); |
|
| 74 | 74 | |
| 75 | - $this->data = ( $trim ) |
|
| 76 | - ? $this->transform_array_leafs( $data, 'trim' ) |
|
| 75 | + $this->data = ($trim) |
|
| 76 | + ? $this->transform_array_leafs($data, 'trim') |
|
| 77 | 77 | : $data; |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace WFV; |
| 3 | -defined( 'ABSPATH' ) || die(); |
|
| 3 | +defined('ABSPATH') || die(); |
|
| 4 | 4 | |
| 5 | 5 | use WFV\Collection\MessageCollection; |
| 6 | 6 | use WFV\Contract\ValidateInterface; |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @param |
| 40 | 40 | */ |
| 41 | - public function __construct( MessageCollection $messages ) { |
|
| 41 | + public function __construct(MessageCollection $messages) { |
|
| 42 | 42 | $this->messages = $messages; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @return bool |
| 62 | 62 | */ |
| 63 | 63 | public function is_valid() { |
| 64 | - return empty( $this->errors ); |
|
| 64 | + return empty($this->errors); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | * @param array (optional) $params |
| 77 | 77 | * @return self |
| 78 | 78 | */ |
| 79 | - public function validate( ValidateInterface $rule, $field, $value, $optional, $params = false ) { |
|
| 80 | - $params[] = ( $params ) ? $field : false; |
|
| 81 | - $valid = $rule->validate( $value, $optional, $params ); |
|
| 82 | - if( !$valid ){ |
|
| 83 | - $this->add_error( $field, $rule->template() ); |
|
| 79 | + public function validate(ValidateInterface $rule, $field, $value, $optional, $params = false) { |
|
| 80 | + $params[] = ($params) ? $field : false; |
|
| 81 | + $valid = $rule->validate($value, $optional, $params); |
|
| 82 | + if (!$valid) { |
|
| 83 | + $this->add_error($field, $rule->template()); |
|
| 84 | 84 | } |
| 85 | 85 | return $this; |
| 86 | 86 | } |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | * @param string $field |
| 95 | 95 | * @param array $template |
| 96 | 96 | */ |
| 97 | - protected function add_error( $field, array $template ) { |
|
| 98 | - $message = ( $this->messages->has( $field ) ) |
|
| 99 | - ? $this->messages->get_msg( $field, $template['name'] ) |
|
| 97 | + protected function add_error($field, array $template) { |
|
| 98 | + $message = ($this->messages->has($field)) |
|
| 99 | + ? $this->messages->get_msg($field, $template['name']) |
|
| 100 | 100 | : $template['message']; |
| 101 | - $this->errors[ $field ][ $template['name'] ] = $message; |
|
| 101 | + $this->errors[$field][$template['name']] = $message; |
|
| 102 | 102 | } |
| 103 | 103 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace WFV\Agent; |
| 3 | -defined( 'ABSPATH' ) || die(); |
|
| 3 | +defined('ABSPATH') || die(); |
|
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @param string $action |
| 28 | 28 | */ |
| 29 | - public function __construct( $action ) { |
|
| 29 | + public function __construct($action) { |
|
| 30 | 30 | $this->action = $action; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | * @return bool |
| 41 | 41 | */ |
| 42 | 42 | public function safe_submit() { |
| 43 | - if( $this->submit_has_action() ) { |
|
| 44 | - return ( $_POST['action'] === $this->action ) ? $this->nonce() : false; |
|
| 43 | + if ($this->submit_has_action()) { |
|
| 44 | + return ($_POST['action'] === $this->action) ? $this->nonce() : false; |
|
| 45 | 45 | } |
| 46 | 46 | return false; |
| 47 | 47 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @return bool |
| 55 | 55 | */ |
| 56 | 56 | private function submit_has_action() { |
| 57 | - return isset( $_POST['action'] ); |
|
| 57 | + return isset($_POST['action']); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | * @return bool |
| 67 | 67 | */ |
| 68 | 68 | private function nonce() { |
| 69 | - $nonce = $_REQUEST[ $this->action.'_token' ]; |
|
| 70 | - return ( wp_verify_nonce( $nonce, $this->action ) ) ? true : false; |
|
| 69 | + $nonce = $_REQUEST[$this->action.'_token']; |
|
| 70 | + return (wp_verify_nonce($nonce, $this->action)) ? true : false; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace WFV\Artisan; |
| 3 | -defined( 'ABSPATH' ) || die(); |
|
| 3 | +defined('ABSPATH') || die(); |
|
| 4 | 4 | |
| 5 | 5 | use WFV\Agent\InspectionAgent; |
| 6 | 6 | use WFV\Contract\ArtisanInterface; |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @param array $config |
| 62 | 62 | */ |
| 63 | - public function __construct( array $config ) { |
|
| 63 | + public function __construct(array $config) { |
|
| 64 | 64 | $this->config = $config; |
| 65 | 65 | } |
| 66 | 66 | |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | * @param string $action |
| 84 | 84 | * @return WFV\Artisan\FormArtisan |
| 85 | 85 | */ |
| 86 | - public function create( $action ) { |
|
| 87 | - $this->form = new FormComposite( $this, $action ); |
|
| 86 | + public function create($action) { |
|
| 87 | + $this->form = new FormComposite($this, $action); |
|
| 88 | 88 | return $this; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @return WFV\Artisan\FormArtisan |
| 98 | 98 | */ |
| 99 | 99 | public function errors() { |
| 100 | - $this->collection['errors'] = new ErrorCollection( $this->labels() ); |
|
| 100 | + $this->collection['errors'] = new ErrorCollection($this->labels()); |
|
| 101 | 101 | return $this; |
| 102 | 102 | } |
| 103 | 103 | |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | * @param InspectionAgent $guard |
| 111 | 111 | * @return WFV\Artisan\FormArtisan |
| 112 | 112 | */ |
| 113 | - public function input( InspectionAgent $guard ) { |
|
| 114 | - $this->collection['input'] = new InputCollection( $guard ); |
|
| 113 | + public function input(InspectionAgent $guard) { |
|
| 114 | + $this->collection['input'] = new InputCollection($guard); |
|
| 115 | 115 | return $this; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -125,10 +125,10 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function rules() { |
| 127 | 127 | $rules = array(); |
| 128 | - foreach( $this->config as $field => $options ) { |
|
| 129 | - $rules[ $field ] = $options['rules']; |
|
| 128 | + foreach ($this->config as $field => $options) { |
|
| 129 | + $rules[$field] = $options['rules']; |
|
| 130 | 130 | } |
| 131 | - $this->collection['rules'] = new RuleCollection( $rules ); |
|
| 131 | + $this->collection['rules'] = new RuleCollection($rules); |
|
| 132 | 132 | return $this; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * @return WFV\Artisan\FormArtisan |
| 142 | 142 | */ |
| 143 | 143 | public function validator() { |
| 144 | - $this->validator = new Validator( new MessageCollection( $this->config ) ); |
|
| 144 | + $this->validator = new Validator(new MessageCollection($this->config)); |
|
| 145 | 145 | return $this; |
| 146 | 146 | } |
| 147 | 147 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * @return array |
| 156 | 156 | */ |
| 157 | 157 | protected function labels() { |
| 158 | - return array_map( function( $item ) { |
|
| 158 | + return array_map(function($item) { |
|
| 159 | 159 | return $item['label']; |
| 160 | 160 | }, $this->config); |
| 161 | 161 | } |