Passed
Push — master ( 5fc828...5cd569 )
by Glynn
07:28 queued 05:13
created
src/Validator/Meta_Box_Validator.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
 class Meta_Box_Validator extends Abstract_Validator {
34 34
 
35
-	protected const REQUIRED_FIELDS = array( 'key', 'label' );
35
+	protected const REQUIRED_FIELDS = array('key', 'label');
36 36
 
37 37
 	/**
38 38
 	 * Validates the class passed.
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @param \PinkCrab\Registerables\Module\Middleware\Registerable $object
41 41
 	 * @return bool
42 42
 	 */
43
-	public function validate( Registerable $object ): bool { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
43
+	public function validate(Registerable $object): bool { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
44 44
 		return false; //no op
45 45
 	}
46 46
 
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
 	 * @param mixed $meta_box
51 51
 	 * @return bool
52 52
 	 */
53
-	public function verify_meta_box( $meta_box ): bool {
53
+	public function verify_meta_box($meta_box): bool {
54 54
 		// If this is not a valid post type, just bail here.
55
-		if ( ! is_object( $meta_box ) || ! is_a( $meta_box, Meta_Box::class ) ) {
56
-			$this->add_error( sprintf( '%s is not a valid Meta Box Model', is_object( $meta_box ) ? get_class( $meta_box ) : \gettype( $meta_box ) ) );
55
+		if ( ! is_object($meta_box) || ! is_a($meta_box, Meta_Box::class)) {
56
+			$this->add_error(sprintf('%s is not a valid Meta Box Model', is_object($meta_box) ? get_class($meta_box) : \gettype($meta_box)));
57 57
 			return false;
58 58
 		}
59 59
 
60 60
 		/* @var Meta_Box $object, already confirmed as a post type */
61 61
 
62 62
 		// Ensure all required fields are set.
63
-		$this->has_required_fields( $meta_box );
63
+		$this->has_required_fields($meta_box);
64 64
 
65 65
 		// Ensure can render view.
66
-		$this->has_valid_view( $meta_box );
66
+		$this->has_valid_view($meta_box);
67 67
 
68 68
 		// Check if the passed object has any errors.
69 69
 		return ! $this->has_errors();
@@ -75,12 +75,12 @@  discard block
 block discarded – undo
75 75
 	 * @param Meta_Box $meta_box
76 76
 	 * @return void
77 77
 	 */
78
-	protected function has_required_fields( Meta_Box $meta_box ): void {
79
-		foreach ( self::REQUIRED_FIELDS as $field ) {
80
-			if ( ! is_string( $meta_box->{$field} )
81
-			|| \mb_strlen( $meta_box->{$field} ) === 0
78
+	protected function has_required_fields(Meta_Box $meta_box): void {
79
+		foreach (self::REQUIRED_FIELDS as $field) {
80
+			if ( ! is_string($meta_box->{$field} )
81
+			|| \mb_strlen($meta_box->{$field} ) === 0
82 82
 			) {
83
-				$this->add_error( sprintf( '%s is not set on %s Meta Box Model', $field, get_class( $meta_box ) ) );
83
+				$this->add_error(sprintf('%s is not set on %s Meta Box Model', $field, get_class($meta_box)));
84 84
 			}
85 85
 		}
86 86
 	}
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 	 * @param \PinkCrab\Registerables\Meta_Box $meta_box
93 93
 	 * @return void
94 94
 	 */
95
-	protected function has_valid_view( Meta_Box $meta_box ): void {
96
-		if ( ! \is_callable( $meta_box->view )
97
-		&& ( ! is_string( $meta_box->view_template ) || \mb_strlen( $meta_box->view_template ) === 0 )
95
+	protected function has_valid_view(Meta_Box $meta_box): void {
96
+		if ( ! \is_callable($meta_box->view)
97
+		&& ( ! is_string($meta_box->view_template) || \mb_strlen($meta_box->view_template) === 0)
98 98
 		) {
99
-			$this->add_error( sprintf( '%s doesn\'t have a valid view defined.', get_class( $meta_box ) ) );
99
+			$this->add_error(sprintf('%s doesn\'t have a valid view defined.', get_class($meta_box)));
100 100
 		}
101 101
 	}
102 102
 }
Please login to merge, or discard this patch.
src/Validator/Abstract_Validator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * @return bool
42 42
 	 */
43 43
 	public function has_errors(): bool {
44
-		return count( $this->errors ) >= 1;
44
+		return count($this->errors) >= 1;
45 45
 	}
46 46
 
47 47
 	/**
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 * @param string $error
60 60
 	 * @return self
61 61
 	 */
62
-	public function add_error( string $error ): self {
62
+	public function add_error(string $error): self {
63 63
 		$this->errors[] = $error;
64 64
 		return $this;
65 65
 	}
@@ -80,5 +80,5 @@  discard block
 block discarded – undo
80 80
 	 * @param \PinkCrab\Registerables\Module\Middleware\Registerable $object
81 81
 	 * @return bool
82 82
 	 */
83
-	abstract public function validate( Registerable $object ): bool;
83
+	abstract public function validate(Registerable $object): bool;
84 84
 }
Please login to merge, or discard this patch.