Passed
Push — master ( 834a6d...ff4a25 )
by Jean-Christophe
01:58
created

ValidatorsManagerInitTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A initModelsValidators() 0 8 3
A registerType() 0 2 1
1
<?php
2
3
namespace Ubiquity\contents\validation;
4
5
use Ubiquity\cache\CacheManager;
6
7
trait ValidatorsManagerInitTrait {
8
	/**
9
	 * Parses models and save validators in cache
10
	 * to use in dev only
11
	 * @param array $config
12
	 */
13
	public static function initModelsValidators(&$config){
14
		$models=CacheManager::getModels($config,true);
15
		foreach ($models as $model){
16
			$parser=new ValidationModelParser();
17
			$parser->parse($model);
18
			$validators=$parser->getValidators();
19
			if(sizeof($validators)>0){
20
				self::store($model, $parser->__toString());
21
			}
22
		}
23
	}
24
	
25
	/**
26
	 * Registers a validator type for using with @validator annotation
27
	 * @param string $type
28
	 * @param string $validatorClass
29
	 */
30
	public static function registerType($type,$validatorClass){
31
		self::$validatorTypes[$type]=$validatorClass;
0 ignored issues
show
Bug Best Practice introduced by
The property validatorTypes does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
32
	}
33
}
34
35