ReflectionFilesystem   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
c 1
b 0
f 1
dl 0
loc 20
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A instance() 0 3 1
A isDefault() 0 6 1
A __construct() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of the sj-i/php-fuse package.
5
 *
6
 * (c) sji <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Fuse\Filesystem;
15
16
use Fuse\FilesystemDefaultImplementationTrait;
17
use Fuse\FilesystemInterface;
18
use ReflectionClass;
19
20
final class ReflectionFilesystem
21
{
22
    private FilesystemInterface $filesystem;
23
24
    public function __construct(FilesystemInterface $filesystem)
25
    {
26
        $this->filesystem = $filesystem;
27
    }
28
29
    public static function instance(FilesystemInterface $filesystem): self
30
    {
31
        return new self($filesystem);
32
    }
33
34
    public function isDefault(string $method_name): bool
35
    {
36
        $class = new ReflectionClass($this->filesystem);
37
        $method = $class->getMethod($method_name);
38
        $trait = new ReflectionClass(FilesystemDefaultImplementationTrait::class);
39
        return $method->getFileName() === $trait->getFileName();
40
    }
41
}
42