Distable::modify()   A
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 5
c 0
b 0
f 0
nc 3
nop 3
dl 0
loc 11
rs 9.6111
1
<?php
2
3
namespace Bavix\Geo\Unit;
4
5
use Bavix\Geo\Value\Valable;
6
7
abstract class Distable implements DistanceInterface
8
{
9
10
    /**
11
     * @param Valable $object
12
     * @param string $name
13
     * @param string $prop
14
     * @return mixed
15
     */
16
    public static function modify(Valable $object, string $name, string $prop)
17
    {
18
        if ($name === Distance::PROPERTY_MILES && $prop === static::property()) {
19
            return $object->$name * static::oneMile();
20
        }
21
22
        if ($prop === Distance::PROPERTY_MILES && $name === static::property()) {
23
            $object->$prop = $object->$name / static::oneMile();
24
        }
25
26
        return null;
27
    }
28
29
}
30