Test Failed
Push — main ( f24735...83b0dc )
by Rafael
11:53
created

Module   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 38
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getEnabledModules() 0 3 1
A __construct() 0 8 1
A getAllModules() 0 3 1
1
<?php
2
/**
3
 * Copyright (C) 2022-2023  Rafael San José Tovar   <[email protected]>
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
 */
18
19
namespace Alxarafe\Models;
20
21
use Alxarafe\Core\Base\Table;
22
23
/**
24
 * Class Module
25
 *
26
 * @package Modules\Main\Models
27
 */
28
class Module extends Table
29
{
30
    /**
31
     * Module constructor.
32
     *
33
     * @param bool $create
34
     */
35
    public function __construct(bool $create = true)
36
    {
37
        parent::__construct(
38
            'modules',
39
            [
40
                'idField' => 'id',
41
                'nameField' => 'name',
42
                'create' => $create,
43
            ]
44
        );
45
    }
46
47
    /**
48
     * Returns an ordered list of enabled modules.
49
     *
50
     * @return Module[]
51
     */
52
    public function getEnabledModules(): array
53
    {
54
        return $this->getAllRecordsBy('enabled', 'NULL', '<>', '`enabled` DESC');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getAllReco...'<>', '`enabled` DESC') returns the type string which is incompatible with the type-hinted return array.
Loading history...
Bug introduced by
The method getAllRecordsBy() does not exist on Alxarafe\Models\Module. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

54
        return $this->/** @scrutinizer ignore-call */ getAllRecordsBy('enabled', 'NULL', '<>', '`enabled` DESC');
Loading history...
55
    }
56
57
58
    /**
59
     * Returns a list of modules.
60
     *
61
     * @return Module[]
62
     */
63
    public function getAllModules(): array
64
    {
65
        return $this->getAllRecords();
66
    }
67
}
68