Completed
Push — master ( dd11e3...886d11 )
by Carsten
02:34 queued 12s
created

GeoDataAwareTrait::setGeoData()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.8666
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 3
1
<?php
2
namespace Germania\GeoData;
3
4
trait GeoDataAwareTrait
5
{
6
7
    use GeoDataProviderTrait;
8
9
10
11
    /**
12
     * @param GeoDataInterface|GeoDataProviderInterface
13
     * @return self
14
     */
15 12
    public function setGeoData( $geodata )
16
    {
17 12
        if ($geodata instanceOf GeoDataInterface):
18 2
            $this->geodata = $geodata;
19 10
        elseif ($geodata instanceOf GeoDataProviderInterface):
20 2
            $this->geodata = $geodata->getGeoData();
21
        else:
22 8
            throw new \InvalidArgumentException("GeoDataInterface or GeoDataProviderInterface expected");
23
        endif;
24
25 4
        return $this;
26
    }
27
28
}
29