Completed
Push — master ( 94ddbb...e5219e )
by Jean-Christophe
04:25
created

ValidatorsManagerInitTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
wmc 4
eloc 9
dl 0
loc 25
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerType() 0 2 1
A initModelsValidators() 0 8 3
1
<?php
2
3
namespace Ubiquity\contents\validation;
4
5
use Ubiquity\cache\CacheManager;
6
7
/**
8
 * @author jcheron <[email protected]>
9
 * @property array $validatorTypes
10
 */
11
trait ValidatorsManagerInitTrait {
12
	/**
13
	 * Parses models and save validators in cache
14
	 * to use in dev only
15
	 * @param array $config
16
	 */
17 1
	public static function initModelsValidators(&$config){
18 1
		$models=CacheManager::getModels($config,true);
19 1
		foreach ($models as $model){
20 1
			$parser=new ValidationModelParser();
21 1
			$parser->parse($model);
22 1
			$validators=$parser->getValidators();
23 1
			if(sizeof($validators)>0){
24 1
				self::store($model, $parser->__toString());
25
			}
26
		}
27 1
	}
28
	
29
	/**
30
	 * Registers a validator type for using with @validator annotation
31
	 * @param string $type
32
	 * @param string $validatorClass
33
	 */
34
	public static function registerType($type,$validatorClass){
35
		self::$validatorTypes[$type]=$validatorClass;
36
	}
37
}
38
39