Passed
Push — master ( 1908fb...8df30e )
by Rougin
03:01
created

Update::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Rougin\Windstorm\Eloquent;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Rougin\Windstorm\UpdateInterface;
7
8
/**
9
 * Update Query
10
 *
11
 * @package Windstorm
12
 * @author  Rougin Gutib <[email protected]>
13
 */
14
class Update implements UpdateInterface
15
{
16
    /**
17
     * @var \Illuminate\Database\Eloquent\Builder
18
     */
19
    protected $builder;
20
21
    /**
22
     * @var array
23
     */
24
    protected $data = array();
25
26
    /**
27
     * @var \Rougin\Windstorm\Eloquent\Query
28
     */
29
    protected $query;
30
31
    /**
32
     * Initializes the query instance.
33
     *
34
     * @param \Rougin\Windstorm\Eloquent\Query      $query
35
     * @param \Illuminate\Database\Eloquent\Builder $builder
36
     */
37 6
    public function __construct(Query $query, Builder $builder)
38
    {
39 6
        $this->query = $query;
40
41 6
        $this->builder = $builder;
42 6
    }
43
44
    /**
45
     * Sets a new value for a column.
46
     *
47
     * @param  string $key
48
     * @param  mixed  $value
49
     * @return self
50
     */
51 6
    public function set($key, $value)
52
    {
53 6
        $this->data[$key] = $value;
54
55 6
        return $this;
56
    }
57
58
    /**
59
     * Generates a WHERE query.
60
     *
61
     * @param  string $key
62
     * @return \Rougin\Windstorm\WhereInterface
63
     */
64 6
    public function where($key)
65
    {
66 6
        $this->query->data($this->data);
67
68 6
        return $this->query->where($key);
69
    }
70
}
71