ComposeFile   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 10.42 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 0
dl 5
loc 48
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 12 2
A getFileName() 0 4 1
A setFileName() 0 5 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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