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

DnsDockResolver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
c 3
b 0
f 0
lcom 0
cbo 0
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getDnsByContainerNameAndImage() 0 9 1
A stripTagNameFromImageName() 0 8 2
1
<?php
2
3
namespace Dock\Docker\Dns;
4
5
class DnsDockResolver implements ContainerAddressResolver
6
{
7
    /**
8
     * {@inheritdoc}
9
     */
10
    public function getDnsByContainerNameAndImage($containerName, $imageName)
11
    {
12
        $imageName = $this->stripTagNameFromImageName($imageName);
13
14
        return [
15
            $imageName.'.docker',
16
            $containerName.'.'.$imageName.'.docker',
17
        ];
18
    }
19
20
    /**
21
     * @param string $imageName
22
     *
23
     * @return string
24
     */
25
    private function stripTagNameFromImageName($imageName)
26
    {
27
        if (false !== ($position = strpos($imageName, ':'))) {
28
            $imageName = substr($imageName, 0, $position);
29
        }
30
31
        return $imageName;
32
    }
33
}
34