Module   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 63
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A updateByIdAndArray() 0 9 1
A enableById() 0 9 1
A disableById() 0 9 1
1
<?php
2
namespace Redaxscript\Admin\Model;
3
4
use Redaxscript\Model as BaseModel;
5
6
/**
7
 * parent class to provide the admin module model
8
 *
9
 * @since 4.0.0
10
 *
11
 * @package Redaxscript
12
 * @category Model
13
 * @author Henry Ruhs
14
 */
15
16
class Module extends BaseModel\Module
17
{
18
	/**
19
	 * update the module by id and array
20
	 *
21
	 * @since 4.0.0
22
	 *
23
	 * @param int $moduleId identifier of the module
24
	 * @param array $updateArray array of the update
25
	 *
26
	 * @return bool
27
	 */
28
29
	public function updateByIdAndArray(int $moduleId = null, array $updateArray = []) : bool
30
	{
31
		return $this
32
			->query()
33
			->whereIdIs($moduleId)
34
			->findOne()
35
			->set($updateArray)
36
			->save();
37
	}
38
39
	/**
40
	 * enable the module by id
41
	 *
42
	 * @since 4.0.0
43
	 *
44
	 * @param int $moduleId identifier of the module
45
	 *
46
	 * @return bool
47
	 */
48
49
	public function enableById(int $moduleId = null) : bool
50
	{
51
		return $this
52
			->query()
53
			->whereIdIs($moduleId)
54
			->findOne()
55
			->set('status', 1)
56
			->save();
57
	}
58
59
	/**
60
	 * disable the module by id
61
	 *
62
	 * @since 4.0.0
63
	 *
64
	 * @param int $moduleId identifier of the module
65
	 *
66
	 * @return bool
67
	 */
68
69
	public function disableById(int $moduleId = null) : bool
70
	{
71
		return $this
72
			->query()
73
			->whereIdIs($moduleId)
74
			->findOne()
75
			->set('status', 0)
76
			->save();
77
	}
78
}
79