RestActionBase::getResourceForMethod()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 7
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/Rest/Traits/Actions/RestActionBase.php
5
 *
6
 * @author TLe, Tarmo Leppänen <[email protected]>
7
 */
8
9
namespace App\Rest\Traits\Actions;
10
11
use App\Rest\Interfaces\RestResourceInterface;
12
use Symfony\Component\HttpFoundation\Request;
13
14
/**
15
 * Trait RestActionBase
16
 *
17
 * @package App\Rest\Traits\Methods
18
 * @author TLe, Tarmo Leppänen <[email protected]>
19
 */
20
trait RestActionBase
21
{
22
    /**
23
     * @param array<int, string> $allowedHttpMethods
24
     */
25 293
    public function getResourceForMethod(Request $request, array $allowedHttpMethods): RestResourceInterface
26
    {
27
        // Make sure that we have everything we need to make this work
28 293
        $this->validateRestMethod($request, $allowedHttpMethods);
0 ignored issues
show
Bug introduced by
It seems like validateRestMethod() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        $this->/** @scrutinizer ignore-call */ 
29
               validateRestMethod($request, $allowedHttpMethods);
Loading history...
29
30
        // Get current resource service
31 210
        return $this->getResource();
0 ignored issues
show
Bug introduced by
The method getResource() does not exist on App\Rest\Traits\Actions\RestActionBase. Did you maybe mean getResourceForMethod()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
        return $this->/** @scrutinizer ignore-call */ getResource();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
    }
33
}
34