Passed
Push — master ( a14668...23f3c2 )
by Rougin
02:42
created

Result::first()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Rougin\Windstorm\Eloquent;
4
5
use Illuminate\Support\Collection;
6
use Rougin\Windstorm\QueryInterface;
7
use Rougin\Windstorm\ResultInterface;
8
9
/**
10
 * Result
11
 *
12
 * @package Windstorm
13
 * @author  Rougin Gutib <[email protected]>
14
 */
15
class Result implements ResultInterface
16
{
17
    /**
18
     * @var \Illuminate\Support\Collection
19
     */
20
    protected $result;
21
22
    /**
23
     * Returns a number of affected rows.
24
     *
25
     * @return integer
26
     */
27
    public function affected()
28
    {
29
        return $this->result->count();
30
    }
31
32
    /**
33
     * Returns a result from a query instance.
34
     *
35
     * @param  \Rougin\Windstorm\QueryInterface $query
36
     * @return \Rougin\Windstorm\ResultInterface
37
     */
38 3
    public function execute(QueryInterface $query)
39
    {
40 3
        $this->result = $query->instance()->get();
41
42 3
        return $this;
43
    }
44
45
    /**
46
     * Returns the first row from result.
47
     *
48
     * @return mixed
49
     */
50 3
    public function first()
51
    {
52 3
        return $this->result->first();
53
    }
54
55
    /**
56
     * Returns the first row from result.
57
     *
58
     * @return mixed
59
     */
60
    public function items()
61
    {
62
        return $this->result;
63
    }
64
}
65