Completed
Push — master ( a4b464...14c945 )
by Henry
09:00
created

includes/Model/Module.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Redaxscript\Model;
3
4
/**
5
 * parent class to provide the module model
6
 *
7
 * @since 3.3.0
8
 *
9
 * @package Redaxscript
10
 * @category Model
11
 * @author Henry Ruhs
12
 */
13
14
class Module extends ModelAbstract
15
{
16
	/**
17
	 * name of the table
18
	 *
19
	 * @var string
20
	 */
21
22
	protected $_table = 'modules';
23
24
	/**
25
	 * create the module by array
26
	 *
27
	 * @since 3.3.0
28
	 *
29
	 * @param array $createArray array of the create
30
	 *
31
	 * @return bool
32
	 */
33
34
	public function createByArray(array $createArray = []) : bool
35
	{
36
		return $this
37
			->query()
38
			->create()
39
			->set($createArray)
40
			->save();
41
	}
42
43
	/**
44
	 * delete the module by alias
45
	 *
46
	 * @since 3.3.0
47
	 *
48
	 * @param string $moduleAlias alias of the module
49
	 *
50
	 * @return bool
51
	 */
52
53
	public function deleteByAlias(string $moduleAlias = null) : bool
54
	{
55
		return $this->query()->where('alias', $moduleAlias)->deleteMany();
0 ignored issues
show
Documentation Bug introduced by
The method deleteMany does not exist on object<Redaxscript\Db>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
56
	}
57
}
58