Completed
Push — master ( 95a54c...7178fa )
by Samuel
10:58
created

ConfiguredContainers::findAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Dock\Docker\Containers;
4
5
class ConfiguredContainers
6
{
7
    /**
8
     * @var ConfiguredContainerIds
9
     */
10
    private $configuredContainerIds;
11
12
    /**
13
     * @var ContainerDetails
14
     */
15
    private $containerDetails;
16
17
    /**
18
     * @param ConfiguredContainerIds $configuredContainerIds
19
     * @param ContainerDetails       $containerDetails
20
     */
21
    public function __construct(ConfiguredContainerIds $configuredContainerIds, ContainerDetails $containerDetails)
22
    {
23
        $this->configuredContainerIds = $configuredContainerIds;
24
        $this->containerDetails = $containerDetails;
25
    }
26
27
    /**
28
     * @return Container[]
29
     */
30
    public function findAll()
31
    {
32
        return array_map([$this, 'findContainerById'], $this->getRunningContainerIds());
33
    }
34
35
    /**
36
     * @return array
37
     */
38
    private function getRunningContainerIds()
39
    {
40
        return $this->configuredContainerIds->findAll();
41
    }
42
43
    /**
44
     * @param string $containerId
45
     *
46
     * @return Container
47
     */
48
    private function findContainerById($containerId)
49
    {
50
        return $this->containerDetails->findById($containerId);
51
    }
52
}
53