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

Result::asArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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 Result
19
 * @package Quantum\Libraries\Database\Idiorm\Statements
20
 */
21
trait Result
22
{
23
24
    /**
25
     * @inheritDoc
26
     */
27
    public function findOne(int $id): object
28
    {
29
        $result = $this->getOrmModel()->find_one($id);
0 ignored issues
show
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
        $result = $this->/** @scrutinizer ignore-call */ getOrmModel()->find_one($id);
Loading history...
30
        return $result ?: $this->getOrmModel();
31
    }
32
33
    /**
34
     * @inheritDoc
35
     */
36
    public function findOneBy(string $column, $value): object
37
    {
38
        $result = $this->getOrmModel()->where($column, $value)->find_one();
39
        return $result ?: $this->getOrmModel();
40
    }
41
42
    /**
43
     * @inheritDoc
44
     */
45
    public function first(): object
46
    {
47
        $result = $this->getOrmModel()->find_one();
48
        return $result ?: $this->getOrmModel();
49
    }
50
51
    /**
52
     * @inheritDoc
53
     */
54
    public function count(): int
55
    {
56
        return $this->getOrmModel()->count();
57
    }
58
59
    /**
60
     * @inheritDoc
61
     */
62
    public function asArray(): array
63
    {
64
        return $this->getOrmModel()->as_array();
65
    }
66
67
}