@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace WFV\Rules; |
| 3 | -defined( 'ABSPATH' ) || die(); |
|
| 3 | +defined('ABSPATH') || die(); |
|
| 4 | 4 | |
| 5 | 5 | use WFV\Contract\ValidateInterface; |
| 6 | 6 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @since 0.11.0 |
| 27 | 27 | * |
| 28 | 28 | */ |
| 29 | - public function __construct( $validator ) { |
|
| 29 | + public function __construct($validator) { |
|
| 30 | 30 | $this->validator = $validator; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -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 \Respect\Validation\Validator as RespectValidator; |
| 6 | 6 | use WFV\Rules; |
@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | * @param string $rule |
| 30 | 30 | * @return ValidateInterface|bool |
| 31 | 31 | */ |
| 32 | - public function get( $rule ) { |
|
| 33 | - if ( !isset( $this->pool[ $rule ] ) ) { |
|
| 34 | - $this->pool[ $rule ] = $this->create( $rule ); |
|
| 32 | + public function get($rule) { |
|
| 33 | + if (!isset($this->pool[$rule])) { |
|
| 34 | + $this->pool[$rule] = $this->create($rule); |
|
| 35 | 35 | } |
| 36 | - return $this->pool[ $rule ]; |
|
| 36 | + return $this->pool[$rule]; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | * @param string $rule |
| 46 | 46 | * @return string |
| 47 | 47 | */ |
| 48 | - protected function class_name( $rule ){ |
|
| 49 | - $name = str_replace(' ', '', ucwords( str_replace('_', ' ', $rule ) ) ); |
|
| 48 | + protected function class_name($rule) { |
|
| 49 | + $name = str_replace(' ', '', ucwords(str_replace('_', ' ', $rule))); |
|
| 50 | 50 | return 'WFV\Rules\\'.$name; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | * @param string $rule |
| 59 | 59 | * @return ValidateInterface |
| 60 | 60 | */ |
| 61 | - protected function create( $rule ) { |
|
| 62 | - $class = $this->class_name( $rule ); |
|
| 63 | - return new $class( new RespectValidator() ); |
|
| 61 | + protected function create($rule) { |
|
| 62 | + $class = $this->class_name($rule); |
|
| 63 | + return new $class(new RespectValidator()); |
|
| 64 | 64 | } |
| 65 | 65 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -defined( 'ABSPATH' ) || die(); |
|
| 2 | +defined('ABSPATH') || die(); |
|
| 3 | 3 | /* |
| 4 | 4 | Plugin Name: WFV - Form Validation |
| 5 | 5 | Plugin URI: https://macder.github.io/wfv/ |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | License URI: https://github.com/macder/wfv-validation/blob/master/LICENSE |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -define( 'WFV_VALIDATE_VERSION', '0.12.1' ); |
|
| 15 | -define( 'WFV_VALIDATE__MINIMUM_WP_VERSION', '3.7' ); |
|
| 16 | -define( 'WFV_VALIDATE__PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
|
| 14 | +define('WFV_VALIDATE_VERSION', '0.12.1'); |
|
| 15 | +define('WFV_VALIDATE__MINIMUM_WP_VERSION', '3.7'); |
|
| 16 | +define('WFV_VALIDATE__PLUGIN_DIR', plugin_dir_path(__FILE__)); |
|
| 17 | 17 | |
| 18 | -require_once WFV_VALIDATE__PLUGIN_DIR . '/vendor/autoload.php'; |
|
| 18 | +require_once WFV_VALIDATE__PLUGIN_DIR.'/vendor/autoload.php'; |
|
| 19 | 19 | |
| 20 | 20 | use WFV\FormComposite; |
| 21 | 21 | use WFV\RuleFactory; |
@@ -33,17 +33,17 @@ discard block |
||
| 33 | 33 | * @param array $form Form arguments |
| 34 | 34 | * @param bool $trim Trim whitespace from beginning and end of string |
| 35 | 35 | */ |
| 36 | -function wfv_create( $action, array &$form, $trim = true ) { |
|
| 37 | - $messages = new MessageCollection( $form ); |
|
| 36 | +function wfv_create($action, array &$form, $trim = true) { |
|
| 37 | + $messages = new MessageCollection($form); |
|
| 38 | 38 | |
| 39 | - $builder = new FormArtisan( $form, $action ); |
|
| 40 | - $form = ( new Director() ) |
|
| 41 | - ->with( 'input' ) |
|
| 42 | - ->with( 'rules' ) |
|
| 43 | - ->with( 'errors' ) |
|
| 44 | - ->compose( $builder ); |
|
| 39 | + $builder = new FormArtisan($form, $action); |
|
| 40 | + $form = (new Director()) |
|
| 41 | + ->with('input') |
|
| 42 | + ->with('rules') |
|
| 43 | + ->with('errors') |
|
| 44 | + ->compose($builder); |
|
| 45 | 45 | |
| 46 | - if( $form->input()->is_populated() ) { |
|
| 47 | - ( new Validator( new RuleFactory(), $messages ) )->validate( $form ); |
|
| 46 | + if ($form->input()->is_populated()) { |
|
| 47 | + (new Validator(new RuleFactory(), $messages))->validate($form); |
|
| 48 | 48 | } |
| 49 | 49 | } |