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
Pull Request — master (#225)
by joseph
39:33
created

Writer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 24
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createDirectoryIfRequired() 0 5 2
A write() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\File;
6
7
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\File;
8
use EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException;
9
10
class Writer
11
{
12
    /**
13
     * Write a file object to the filesystem and return the created path
14
     *
15
     * @param File $file
16
     *
17
     * @return string
18
     * @throws DoctrineStaticMetaException
19
     */
20
    public function write(File $file): string
21
    {
22
        $this->createDirectoryIfRequired($file);
23
        $file->create();
24
        $file->putContents();
25
26
        return $file->getPath();
27
    }
28
29
    private function createDirectoryIfRequired(File $file): void
30
    {
31
        $directory = $file->getDirectory();
32
        if (false === $directory->exists()) {
33
            $directory->create();
34
        }
35
    }
36
}
37