OpauthValidator   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B php() 0 17 5
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