Passed
Pull Request — master (#48)
by Arman
03:56
created

Model   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 33
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 3 1
A get() 0 3 2
A save() 0 3 1
A create() 0 3 1
1
<?php
2
3
/**
4
 * Quantum PHP Framework
5
 *
6
 * An open source software development framework for PHP
7
 *
8
 * @package Quantum
9
 * @author Arman Ag. <[email protected]>
10
 * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
11
 * @link http://quantum.softberg.org/
12
 * @since 2.6.0
13
 */
14
15
namespace Quantum\Libraries\Database\Idiorm\Statements;
16
17
/**
18
 * Trait Model
19
 * @package Quantum\Libraries\Database\Idiorm\Statements
20
 */
21
trait Model
22
{
23
24
    /**
25
     * @inheritDoc
26
     */
27
    public function get(?int $returnType = self::TYPE_ARRAY)
0 ignored issues
show
Bug introduced by
The constant Quantum\Libraries\Databa...ments\Model::TYPE_ARRAY was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
28
    {
29
        return ($returnType == self::TYPE_OBJECT) ? $this->getOrmModel()->find_many() : $this->getOrmModel()->find_array();
0 ignored issues
show
Bug introduced by
The constant Quantum\Libraries\Databa...ents\Model::TYPE_OBJECT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
It seems like getOrmModel() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

29
        return ($returnType == self::TYPE_OBJECT) ? $this->/** @scrutinizer ignore-call */ getOrmModel()->find_many() : $this->getOrmModel()->find_array();
Loading history...
30
    }
31
32
    /**
33
     * @inheritDoc
34
     */
35
    public function create(): object
36
    {
37
        return $this->getOrmModel()->create();
38
    }
39
40
    /**
41
     * @inheritDoc
42
     */
43
    public function save(): bool
44
    {
45
        return $this->getOrmModel()->save();
46
    }
47
48
    /**
49
     * @inheritDoc
50
     */
51
    public function delete(): bool
52
    {
53
        return $this->getOrmModel()->delete();
54
    }
55
56
}