Quantity   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 14
c 0
b 0
f 0
ccs 5
cts 6
cp 0.8333
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A findUnit() 0 11 3
1
<?php
2
/**
3
 * PHP Units of Measure Library
4
 *
5
 * @link      https://github.com/hiqdev/php-units
6
 * @package   php-units
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\units;
12
13
use hiqdev\php\units\exceptions\InvalidArgumentException;
14
15
/**
16
 * Quantity with Unit.
17
 *
18
 * @author Andrii Vasyliev <[email protected]>
19
 */
20
final class Quantity extends AbstractQuantity
21
{
22 11
    protected static function findUnit($unit)
23
    {
24 11
        if ($unit instanceof UnitInterface) {
25 6
            return $unit;
26
        }
27 11
        if (!is_string($unit)) {
28
            throw new InvalidArgumentException('uncompatible unit name: ' . var_export($unit, true));
29
        }
30
31 11
        return Unit::$unit();
32
    }
33
}
34