Completed
Push — master ( eea56f...dd11e3 )
by Carsten
02:43 queued 15s
created

GeoDataAwareTrait::setGeoData()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3.0261

Importance

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