Completed
Branch feature/pre-split (745f0c)
by Anton
03:28
created

InsertCommand::getInsertID()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * components
4
 *
5
 * @author    Wolfy-J
6
 */
7
namespace Spiral\ORM\Commands;
8
9
use Spiral\Database\Entities\Table;
10
11
class InsertCommand extends TableCommand
12
{
13
    /**
14
     * @var array
15
     */
16
    private $context = [];
17
18
    /**
19
     * Set when command is executed.
20
     *
21
     * @var null|mixed
22
     */
23
    private $inserID = null;
24
25
    /**
26
     * @param Table $table
27
     * @param array $context
28
     */
29
    public function __construct(Table $table, array $context)
30
    {
31
        parent::__construct($table);
32
        $this->context = $context;
33
    }
34
35
    /**
36
     * Get inserted row id.
37
     *
38
     * @return mixed|null
39
     */
40
    public function getInsertID()
41
    {
42
        return $this->inserID;
43
    }
44
45
    /**
46
     * Inserting data into associated table.
47
     */
48
    public function execute()
49
    {
50
        $this->inserID = $this->table->insertOne($this->context);
51
52
        parent::execute();
53
    }
54
}
55