Completed
Push — master ( ceb9a8...527314 )
by ARCANEDEV
14s
created

ElevationResponse::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php namespace Arcanedev\GeoLocation\Google\Elevation;
2
3
use Arcanedev\GeoLocation\Google\AbstractResponse;
4
5
/**
6
 * Class     ElevationResponse
7
 *
8
 * @package  Arcanedev\GeoLocation\Google\Elevation
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class ElevationResponse extends AbstractResponse
12
{
13
    /* -----------------------------------------------------------------
14
     |  Properties
15
     | -----------------------------------------------------------------
16
     */
17
18
    /**
19
     * The elevations collection.
20
     *
21
     * @var \Arcanedev\GeoLocation\Google\Elevation\Entities\ElevationCollection
22
     */
23
    protected $elevations;
24
25
    /* -----------------------------------------------------------------
26
     |  Getters & Setters
27
     | -----------------------------------------------------------------
28
     */
29
30
    /**
31
     * Get the elevations collection.
32
     *
33
     * @return \Arcanedev\GeoLocation\Google\Elevation\Entities\ElevationCollection
34
     */
35 9
    public function elevations()
36
    {
37 9
        if (is_null($this->elevations)) {
38 9
            $this->elevations = Entities\ElevationCollection::load(
39 9
                $this->get('results', [])
40 3
            );
41 3
        }
42
43 9
        return $this->elevations;
44
    }
45
46
    /* -----------------------------------------------------------------
47
     |  Main Methods
48
     | -----------------------------------------------------------------
49
     */
50
51
    /**
52
     * Get the instance as an array.
53
     *
54
     * @return array
55
     */
56 3
    public function toArray()
57
    {
58 3
        return $this->elevations()->toArray();
59
    }
60
}
61