OpauthValidator::php()   B
last analyzed

Complexity

Conditions 5
Paths 8

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 17
rs 8.8571
cc 5
eloc 12
nc 8
nop 1
1
<?php
2
3
/**
4
 * OpauthValidator
5
 * Merges with a custom validator to bring to the user some super error messages
6
 * @author Will Morgan <@willmorgan>
7
 */
8
class OpauthValidator extends RequiredFields {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
9
10
	public function php($data) {
11
		$customValid = true;
12
		$requiredValid = parent::php($data);
13
		// If there's a custom validator set, validate with that too
14
		if($validatorClass = self::config()->custom_validator) {
15
			$custom = new $validatorClass();
16
			$custom->setForm($this->form);
17
			$customValid = $custom->php($data);
18
			if(!$customValid) {
19
				if($requiredValid) {
20
					$this->errors = array();
21
				}
22
				$this->errors = array_merge($this->errors, $custom->errors);
23
			}
24
		}
25
		return $customValid && $requiredValid;
26
	}
27
28
}
29