Test Failed
Push — master ( 2c36df...4a4b22 )
by Nuno
01:36
created

ResourceMethodExtension::subject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of Laravel Code Analyse.
7
 *
8
 * (c) Nuno Maduro <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace NunoMaduro\LaravelCodeAnalyse\Http\Resources\Json;
15
16
use Illuminate\Database\Eloquent\Model;
17
use Mockery;
18
use PHPStan\Reflection\ClassReflection;
19
use PHPStan\Reflection\MethodReflection;
20
use Illuminate\Http\Resources\Json\Resource;
21
use NunoMaduro\LaravelCodeAnalyse\AbstractExtension;
22
use ReflectionClass;
23
24
final class ResourceMethodExtension extends AbstractExtension
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    protected function searchIn(ClassReflection $classReflection): array
30
    {
31
        return collect(get_declared_classes())
32
            ->filter(
33
                function ($item) {
34
                    return (new ReflectionClass($item))->isSubclassOf(Model::class);
35
                }
36
            )
37
            ->toArray();
38
    }
39
40
    /**
41
     * Returns the class under analyse.
42
     *
43
     * @return string
44
     */
45
    protected function subject(): string
46
    {
47
        return Resource::class;
48
    }
49
}
50