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