ComposeFile::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 5
Ratio 41.67 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 5
loc 12
rs 9.4285
cc 2
eloc 7
nc 2
nop 0
1
<?php
2
3
4
namespace DockerCompose;
5
6
use Exception;
7
8
/**
9
 * DockerCompose\ComposeFile
10
 */
11
class ComposeFile
12
{
13
    /**
14
     * @var string
15
     */
16
    private $fileName;
17
18
    /**
19
     * @param string
20
     *
21
     * @throws \Exception When the file name is not a string
22
     */
23
    public function __construct()
24
    {
25
        $name = func_get_arg(0);
26
27
        if (is_string($name)) {
28
            $this->setFileName($name);
29 View Code Duplication
        } else {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
            throw new Exception(
31
                'Invalid fileName definition "(' . gettype($name) . ') ' . var_export($name, true) . '"'
32
            );
33
        }
34
    }
35
36
    /**
37
     * Get file name
38
     *
39
     * @return string
40
     */
41
    public function getFileName()
42
    {
43
        return $this->fileName;
44
    }
45
46
    /**
47
     * Set the file name
48
     *
49
     * @param string $fileName The name of file to set
50
     *
51
     * @return ComposeFile
52
     */
53
    public function setFileName($fileName)
54
    {
55
        $this->fileName = $fileName;
56
        return $this;
57
    }
58
}
59