GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Copy   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 70
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getContents() 0 21 4
A getFrom() 0 4 1
A setFrom() 0 6 1
1
<?php
2
namespace Naneau\FileGen\File\Contents;
3
4
use Naneau\FileGen\File\Contents\Exception as ContentsException;
5
use Naneau\FileGen\File\Contents;
6
7
/**
8
 * Contents for a file copied directly from another
9
 */
10
class Copy implements Contents
11
{
12
    /**
13
     * The source file
14
     *
15
     * @var string
16
     **/
17
    private $from;
18
19
    /**
20
     * The source file
21
     *
22
     * @param  string $from
23
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
24
     **/
25
    public function __construct($from)
26
    {
27
        $this->setFrom($from);
28
    }
29
30
    /**
31
     * Get the contents
32
     *
33
     * @return string
34
     **/
35
    public function getContents()
36
    {
37
        // Make sure file exists
38
        if (!file_exists($this->getFrom()) || !is_readable($this->getFrom())) {
39
            throw new ContentsException(sprintf(
40
                'Can not read from "%s"',
41
                $this->getFrom()
42
            ));
43
        }
44
45
        $contents = file_get_contents($this->getFrom());
46
47
        if ($contents === false) {
48
            throw new ContentsException(sprintf(
49
                'Could not read from "%s"',
50
                $this->getFrom()
51
            ));
52
        }
53
54
        return $contents;
55
    }
56
57
    /**
58
     * Get the source file
59
     *
60
     * @return string
61
     */
62
    public function getFrom()
63
    {
64
        return $this->from;
65
    }
66
67
    /**
68
     * Set the source file
69
     *
70
     * @param  string $from
71
     * @return Copy
72
     */
73
    public function setFrom($from)
74
    {
75
        $this->from = $from;
76
77
        return $this;
78
    }
79
}
80