SpeedPointFactory   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 36
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A __invoke() 0 5 3
1
<?php
2
namespace FilmTools\SpeedPoint;
3
4
class SpeedPointFactory
5
{
6
7
    /**
8
     * @var string|null
9
     */
10
    protected $speedpoint_type;
11
12
    /**
13
     * @var string FQDN
14
     */
15
    protected $php_class;
16
17
18
    /**
19
     * @param string|null $speedpoint_type Short SpeedPoint description that all generated instances have in common.
20
     * @param string|null $php_class       FQDN of a SpeedPoint class
21
     */
22
    public function __construct( ?string $speedpoint_type = null, ?string $php_class = null)
23
    {
24
        $this->php_class = $php_class ?: SpeedPoint::class;
25
        $this->speedpoint_type = $speedpoint_type;
26
    }
27
28
    /**
29
     * @param  float      $logH          Exposure value
30
     * @param  string|null $php_class    Optional: FQDN of a SpeedPoint class
31
     * @param  string|null $description  Optional: Custom SpeedPoint description for the new object
32
     * @return SpeedPointInterface
33
     */
34
    public function __invoke( float $logH, ?string $php_class = null, ?string $description = null )
35
    {
36
        $php_class = $php_class ?: $this->php_class;
37
        return new $php_class( $logH, $description ?: $this->speedpoint_type );
38
    }
39
}
40