Unit   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 22
ccs 3
cts 6
cp 0.5
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findConverter() 0 8 2
A findDefaultConverter() 0 4 1
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\tree\TreeConverter;
14
15
/**
16
 * Unit of measure based on TreeConverter implementation.
17
 *
18
 * @author Andrii Vasyliev <[email protected]>
19
 */
20
final class Unit extends AbstractUnit
21
{
22
    private static $defaultConverter;
23
24
    /**
25
     * {@inheritdoc}
26
     * Name is not used. Returns same converter for all units.
27
     */
28 5
    protected static function findConverter($name)
29
    {
30 5
        if (empty(static::$defaultConverter)) {
0 ignored issues
show
Comprehensibility introduced by
Since hiqdev\php\units\Unit is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
31
            static::$defaultConverter = static::findDefaultConverter();
0 ignored issues
show
Comprehensibility introduced by
Since hiqdev\php\units\Unit is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
32
        }
33
34 5
        return static::$defaultConverter;
0 ignored issues
show
Comprehensibility introduced by
Since hiqdev\php\units\Unit is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
35
    }
36
37
    protected static function findDefaultConverter()
38
    {
39
        return new TreeConverter();
40
    }
41
}
42