@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace WFV\Contract; |
| 3 | -defined( 'ABSPATH' ) or die(); |
|
| 3 | +defined('ABSPATH') or die(); |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @return |
| 15 | 15 | */ |
| 16 | - public function create( $action ); |
|
| 16 | + public function create($action); |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * @return |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace WFV\Agent; |
| 3 | -defined( 'ABSPATH' ) or die(); |
|
| 3 | +defined('ABSPATH') or die(); |
|
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @param string $action |
| 37 | 37 | */ |
| 38 | - function __construct( $action ) { |
|
| 38 | + function __construct($action) { |
|
| 39 | 39 | $this->action = $action; |
| 40 | - $this->token = wp_create_nonce( $action ); |
|
| 40 | + $this->token = wp_create_nonce($action); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | * @return bool |
| 51 | 51 | */ |
| 52 | 52 | public function safe_submit() { |
| 53 | - if( $this->submit_has_action() ) { |
|
| 54 | - return ( $_POST['action'] === $this->action ) ? $this->nonce() : false; |
|
| 53 | + if ($this->submit_has_action()) { |
|
| 54 | + return ($_POST['action'] === $this->action) ? $this->nonce() : false; |
|
| 55 | 55 | } |
| 56 | 56 | return false; |
| 57 | 57 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @return bool |
| 65 | 65 | */ |
| 66 | 66 | private function submit_has_action() { |
| 67 | - return isset( $_POST['action'] ); |
|
| 67 | + return isset($_POST['action']); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | * @return bool |
| 77 | 77 | */ |
| 78 | 78 | private function nonce() { |
| 79 | - $nonce = $_REQUEST[ $this->action.'_token' ]; |
|
| 80 | - return ( wp_verify_nonce( $nonce, $this->action ) ) ? true : false; |
|
| 79 | + $nonce = $_REQUEST[$this->action.'_token']; |
|
| 80 | + return (wp_verify_nonce($nonce, $this->action)) ? true : false; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace WFV; |
| 3 | -defined( 'ABSPATH' ) or die(); |
|
| 3 | +defined('ABSPATH') or die(); |
|
| 4 | 4 | |
| 5 | 5 | use WFV\Contract\ValidateInterface; |
| 6 | 6 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @return bool |
| 41 | 41 | */ |
| 42 | 42 | public function is_valid() { |
| 43 | - return empty( $this->errors ); |
|
| 43 | + return empty($this->errors); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | * @param ValidateInterface $rule |
| 52 | 52 | * @param string|array $value |
| 53 | 53 | */ |
| 54 | - public function validate( ValidateInterface $rule, $value ) { |
|
| 55 | - $valid = $rule->validate( $value ); |
|
| 56 | - if( !$valid ){ |
|
| 57 | - $this->add_error( $rule->field_name(), $rule->template() ); |
|
| 54 | + public function validate(ValidateInterface $rule, $value) { |
|
| 55 | + $valid = $rule->validate($value); |
|
| 56 | + if (!$valid) { |
|
| 57 | + $this->add_error($rule->field_name(), $rule->template()); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @param string $field |
| 68 | 68 | * @param array $template |
| 69 | 69 | */ |
| 70 | - protected function add_error( $field, array $template ) { |
|
| 71 | - $this->errors[ $field ][ $template['name'] ] = $template['message']; |
|
| 70 | + protected function add_error($field, array $template) { |
|
| 71 | + $this->errors[$field][$template['name']] = $template['message']; |
|
| 72 | 72 | } |
| 73 | 73 | } |