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.
Passed
Pull Request — master (#214)
by joseph
20:33
created

Writer::write()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
ccs 0
cts 5
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\File;
4
5
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\File;
6
use EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException;
7
8
class Writer
9
{
10
    /**
11
     * Write a file object to the filesystem and return the created path
12
     *
13
     * @param File $file
14
     *
15
     * @return string
16
     * @throws DoctrineStaticMetaException
17
     */
18
    public function write(File $file): string
19
    {
20
        $this->createDirectoryIfRequired($file);
21
        $file->create();
22
        $file->putContents();
23
24
        return $file->getPath();
25
    }
26
27
    private function createDirectoryIfRequired(File $file): void
28
    {
29
        $directory = $file->getDirectory();
30
        if (false === $directory->exists()) {
31
            $directory->create();
32
        }
33
    }
34
}
35