Completed
Push — master ( e43f1a...57db71 )
by Arman
26s queued 12s
created

Model::save()   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
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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.4.0
13
 */
14
namespace Quantum\Libraries\Database\Statements;
15
16
/**
17
 * Trait Model
18
 * @package Quantum\Libraries\Database\Statements
19
 */
20
trait Model
21
{
22
    /**
23
     * Gets the result set
24
     * @inheritDoc
25
     */
26
    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...
27
    {
28
        return ($returnType == self::TYPE_OBJECT) ? $this->ormObject->find_many() : $this->ormObject->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...
29
    }
30
31
    /**
32
     * Creates new db record
33
     * @inheritDoc
34
     */
35
    public function create(): object
36
    {
37
        return $this->ormObject->create();
38
    }
39
40
    /**
41
     * Saves the data into the database
42
     * @inheritDoc
43
     */
44
    public function save(): bool
45
    {
46
        return $this->ormObject->save();
47
    }
48
49
    /**
50
     * Deletes the record from the database
51
     * @inheritDoc
52
     */
53
    public function delete(): bool
54
    {
55
        return $this->ormObject->delete();
56
    }
57
58
}