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.
Completed
Push — master ( 75bdf9...8faa57 )
by joseph
83:56 queued 81:04
created

File   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 122
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 27
dl 0
loc 122
ccs 31
cts 31
cp 1
rs 10
c 0
b 0
f 0
wmc 11

9 Methods

Rating   Name   Duplication   Size   Complexity  
A doCreate() 0 4 1
A putContents() 0 6 1
A getDirectory() 0 3 1
A getContents() 0 3 1
A getSplFileObject() 0 9 3
A setContents() 0 5 1
A setPath() 0 6 1
A isCorrectType() 0 3 1
A loadContents() 0 6 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem;
4
5
class File extends AbstractFilesystemItem
6
{
7
    protected const PATH_TYPE = 'file';
8
9
    /**
10
     * The permissions to be set on newly created files
11
     *
12
     * @var int
13
     */
14
    protected $createMode = 0644;
15
16
    /**
17
     * @var string|null
18
     */
19
    protected $contents;
20
21
    /**
22
     * Stores an instance fo the SplFileObject object for the file.
23
     *
24
     * @var \SplFileObject
25
     */
26
    protected $splFileObject;
27
28
    /**
29
     * @var Directory
30
     */
31
    private $directory;
32
33
    /**
34
     * This is the specific creation logic for the concrete filesystem type.
35
     */
36 6
    protected function doCreate(): void
37
    {
38 6
        $this->directory->assertExists();
39 4
        \ts\file_put_contents($this->path, '');
40 4
    }
41
42
    /**
43
     * @param string $path
44
     *
45
     * @return $this
46
     */
47 9
    public function setPath(string $path)
48
    {
49 9
        parent::setPath($path);
50 9
        $this->directory = new Directory(\dirname($path));
51
52 9
        return $this;
53
    }
54
55
    /**
56
     * @return string
57
     */
58 5
    public function getContents(): ?string
59
    {
60 5
        return $this->contents;
61
    }
62
63
    /**
64
     * @param string $contents
65
     *
66
     * @return File
67
     */
68 1
    public function setContents(string $contents): File
69
    {
70 1
        $this->contents = $contents;
71
72 1
        return $this;
73
    }
74
75
    /**
76
     * @return File
77
     * @throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException
78
     */
79 3
    public function putContents(): self
80
    {
81 3
        $this->assertExists();
82 1
        \ts\file_put_contents($this->path, $this->contents);
0 ignored issues
show
Bug introduced by
It seems like $this->contents can also be of type null; however, parameter $data of ts\file_put_contents() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

82
        \ts\file_put_contents($this->path, /** @scrutinizer ignore-type */ $this->contents);
Loading history...
83
84 1
        return $this;
85
    }
86
87
    /**
88
     * @return File
89
     * @throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException
90
     */
91 3
    public function loadContents(): self
92
    {
93 3
        $this->assertExists();
94 1
        $this->contents = \ts\file_get_contents($this->path);
95
96 1
        return $this;
97
    }
98
99
    /**
100
     * Provide an SplFileObject object, asserting that the path exists
101
     *
102
     * @return \SplFileObject
103
     * @throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException
104
     */
105 4
    public function getSplFileObject(): \SplFileObject
106
    {
107 4
        $this->assertExists();
108 2
        if (null !== $this->splFileObject && $this->path === $this->splFileObject->getRealPath()) {
109 1
            return $this->splFileObject;
110
        }
111 1
        $this->splFileObject = new \SplFileObject($this->path);
112
113 1
        return $this->splFileObject;
114
    }
115
116
    /**
117
     * @return Directory
118
     */
119 1
    public function getDirectory(): Directory
120
    {
121 1
        return $this->directory;
122
    }
123
124 5
    protected function isCorrectType(): bool
125
    {
126 5
        return $this->createSplFileInfo()->isFile();
127
    }
128
}
129