Freighter::getLoadCapacity()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace codenixsv\Patterns\Structural\Composite;
5
6
/**
7
 * Class Freighter
8
 * @package codenixsv\Patterns\Structural\Composite
9
 */
10
class Freighter
11
{
12
    /**
13
     * @var ContainerInterface[]
14
     */
15
    private $containers = [];
16
17 4
    public function addContainer(ContainerInterface $container)
18
    {
19 4
        $this->containers[] = $container;
20 4
    }
21
22
    /**
23
     * @return float
24
     */
25 4
    public function getLoadCapacity()
26
    {
27 4
        $loadCapacity = 0.0;
28
29 4
        foreach ($this->containers as $container) {
30 4
            $loadCapacity += $container->getLoadCapacity();
31
        }
32
33 4
        return $loadCapacity;
34
    }
35
}
36