@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace WFV\Collection; |
| 3 | -defined( 'ABSPATH' ) || die(); |
|
| 3 | +defined('ABSPATH') || die(); |
|
| 4 | 4 | use WFV\Abstraction\Collectable; |
| 5 | 5 | /** |
| 6 | 6 | * |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @param array $form Config array |
| 18 | 18 | */ |
| 19 | - public function __construct( array $form ) { |
|
| 20 | - $this->set_messages( $form ); |
|
| 19 | + public function __construct(array $form) { |
|
| 20 | + $this->set_messages($form); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | * @param string $rule |
| 41 | 41 | * @return array|null |
| 42 | 42 | */ |
| 43 | - public function get_msg( $field, $rule ) { |
|
| 44 | - return ( isset( $this->data[ $field ][ $rule ] ) ) |
|
| 45 | - ? $this->data[ $field ][ $rule ] |
|
| 43 | + public function get_msg($field, $rule) { |
|
| 44 | + return (isset($this->data[$field][$rule])) |
|
| 45 | + ? $this->data[$field][$rule] |
|
| 46 | 46 | : null; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | * @param array $form |
| 57 | 57 | * @return array |
| 58 | 58 | */ |
| 59 | - protected function filter_config( array $form ) { |
|
| 60 | - return array_filter( $form, function( $item ) { |
|
| 61 | - if ( array_key_exists('messages', $item ) ) { |
|
| 59 | + protected function filter_config(array $form) { |
|
| 60 | + return array_filter($form, function($item) { |
|
| 61 | + if (array_key_exists('messages', $item)) { |
|
| 62 | 62 | return !empty($item['messages']); |
| 63 | 63 | } |
| 64 | 64 | }); |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @param array |
| 74 | 74 | */ |
| 75 | - protected function make_array( array $filtered ) { |
|
| 75 | + protected function make_array(array $filtered) { |
|
| 76 | 76 | $messages = array(); |
| 77 | - foreach( $filtered as $field => $options ) { |
|
| 78 | - $messages[ $field ] = $options['messages']; |
|
| 77 | + foreach ($filtered as $field => $options) { |
|
| 78 | + $messages[$field] = $options['messages']; |
|
| 79 | 79 | } |
| 80 | 80 | return $messages; |
| 81 | 81 | } |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @param array $form |
| 90 | 90 | */ |
| 91 | - protected function set_messages( array $form ) { |
|
| 92 | - $filtered = $this->filter_config( $form ); |
|
| 93 | - $this->data = $this->make_array( $filtered ); |
|
| 91 | + protected function set_messages(array $form) { |
|
| 92 | + $filtered = $this->filter_config($form); |
|
| 93 | + $this->data = $this->make_array($filtered); |
|
| 94 | 94 | } |
| 95 | 95 | } |