Passed
Push — 0.3.0 ( 0d73f1...9a02d7 )
by Anton
04:10
created

Pages::init()   D

Complexity

Conditions 9
Paths 1

Size

Total Lines 42
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 42
rs 4.909
cc 9
eloc 17
nc 1
nop 0
1
<?php
2
3
namespace Modules\Entitizer\Collection {
4
5
	use Modules\Entitizer;
6
7
	trait Pages {
8
9
		protected static $order_by = ['title' => 'ASC', 'id' => 'ASC'];
10
11
		# Init collection
12
13
		protected function init() {
14
15
			$this->config->add('active', false, function (bool $active) {
0 ignored issues
show
Bug introduced by
The property config does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
16
17
				return ($active ? ("ent.visibility = " . VISIBILITY_PUBLISHED . " AND ent.locked = 0") : '');
18
			});
19
20
			$this->config->add('rank', null, function (int $rank = null) {
21
22
				return ((null !== $rank) ? ("ent.access <= " . $rank) : '');
23
			});
24
25
			$this->config->add('slug', '', function (string $slug) {
26
27
				return (('' !== $slug) ? ("ent.slug = '" . addslashes($slug) . "'") : '');
28
			});
29
30
			$this->config->add('name', '', function (string $name) {
31
32
				return (('' !== $name) ? ("ent.name = '" . addslashes($name) . "'") : '');
33
			});
34
35
			$this->config->add('time_created >=', 0, function (int $time) {
36
37
				return ((0 < $time) ? ("ent.time_created >= " . $time) : '');
38
			});
39
40
			$this->config->add('time_created <=', 0, function (int $time) {
41
42
				return ((0 < $time) ? ("ent.time_created <= " . $time) : '');
43
			});
44
45
			$this->config->add('time_modified >=', 0, function (int $time) {
46
47
				return ((0 < $time) ? ("ent.time_modified >= " . $time) : '');
48
			});
49
50
			$this->config->add('time_modified <=', 0, function (int $time) {
51
52
				return ((0 < $time) ? ("ent.time_modified <= " . $time) : '');
53
			});
54
		}
55
	}
56
}
57