Passed
Branch master (03df00)
by Anu
06:02 queued 03:32
created

Model::validate()   B

Complexity

Conditions 9
Paths 10

Size

Total Lines 17
Code Lines 12

Duplication

Lines 4
Ratio 23.53 %

Importance

Changes 0
Metric Value
cc 9
eloc 12
nc 10
nop 2
dl 4
loc 17
rs 7.756
c 0
b 0
f 0
1
<?
0 ignored issues
show
Security Best Practice introduced by
It is not recommended to use PHP's short opening tag <?, better use <?php, or <?= in case of outputting.

Short opening tags are disabled in PHP?s default configuration. In such a case, all content of this file is output verbatim to the browser without being parsed, or executed.

As a precaution to avoid these problems better use the long opening tag <?php.

Loading history...
2
3
abstract class Model  extends Cortex {
0 ignored issues
show
Bug introduced by
The type Cortex was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
4
	protected $app;
5
	protected $db = 'DB';
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $db. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
6
	protected $fieldConf = array(
7
		'created_at' => array(
8
			'type' => Schema::DT_TIMESTAMP,
0 ignored issues
show
Bug introduced by
The type Schema was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
			'default' => Schema::DF_CURRENT_TIMESTAMP
10
			),
11
		'updated_at' => array(
12
			'type' => Schema::DT_TIMESTAMP,
13
			'default' => '0-0-0 0:0:0'
14
			),
15
		'deleted_at' => array(
16
			'type' => Schema::DT_TIMESTAMP,
17
			'default' => '0-0-0 0:0:0'
18
			)
19
		);
20
21
	public function __construct() {
22
		if(property_exists($this, 'fields')) {
23
			$this->fieldConf = array_merge($this->fields, $this->fieldConf);
24
		}
25
26
		parent::__construct();
27
		$this->app = f3();
28
		//$this->beforesave($this->validate(get_called_class()));
29
	}
30
31
	/*private function validate($caller, $parent) {
32
		$valid = true;
33
		foreach($this->getFieldConfiguration() as $field => $conf) {
34
			if(isset($conf['type']) && !isset($conf['relType'])){
35
				$val = $this->get($field);
36
				$model = strtolower(str_replace('\\','.',$class));
37
				// check required fields
38
				if ($valid && isset($conf['required']))
39
					$valid = \Validation::instance()->required($val,$field,'error.'.$model.'.'.$field);
40
				// check unique
41
				if ($valid && isset($conf['unique']))
42
					$valid = \Validation::instance()->unique($self,$val,$field,'error.'.$model.'.'.$field);
43
				if (!$valid)
44
					break;
45
			}
46
		}
47
		return $valid;
48
	}*/
49
}