Passed
Push — master ( f0e277...a14668 )
by Rougin
03:58
created

CreateEntity   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A set() 0 3 1
1
<?php
2
3
namespace Rougin\Windstorm\Mutators;
4
5
use Rougin\Windstorm\QueryInterface;
6
use Rougin\Windstorm\MutatorInterface;
7
8
/**
9
 * Create Entity Mutator
10
 *
11
 * @package Windstorm
12
 * @author  Rougin Gutib <[email protected]>
13
 */
14
class CreateEntity implements MutatorInterface
15
{
16
    /**
17
     * @var array
18
     */
19
    protected $data = array();
20
21
    /**
22
     * @var string
23
     */
24
    protected $table = '';
25
26
    /**
27
     * Initializes the mutator instance.
28
     *
29
     * @param array $data
30
     */
31
    public function __construct($data)
32
    {
33
        $this->data = $data;
34
    }
35
36
    /**
37
     * Mutates the specified query instance.
38
     *
39
     * @param \Rougin\Windstorm\QueryInterface $query
40
     */
41
    public function set(QueryInterface $query)
42
    {
43
        return $query->insertInto($this->table)->values($this->data);
44
    }
45
}
46