Passed
Push — master ( 5b5c00...4c0c12 )
by Julien
04:52
created

GetAction::getAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 10
ccs 0
cts 6
cp 0
rs 10
cc 2
nc 2
nop 1
crap 6
1
<?php
2
3
/**
4
 * This file is part of the Zemit Framework.
5
 *
6
 * (c) Zemit Team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.txt
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zemit\Mvc\Controller\Rest\Actions;
13
14
use Phalcon\Http\ResponseInterface;
15
use Zemit\Mvc\Controller\AbstractTrait\AbstractInjectable;
16
17
trait GetAction {
18
    
19
    use AbstractInjectable;
20
    
21
    /**
22
     * @deprecated Should use getAction() method instead
23
     */
24
    public function getSingleAction(string|int $id = null): ResponseInterface
25
    {
26
        return $this->getAction($id);
27
    }
28
    
29
    /**
30
     * Retrieving a single record
31
     */
32
    public function getAction(string|int $id = null): ResponseInterface
33
    {
34
        $entity = $this->getSingle($id);
0 ignored issues
show
Bug introduced by
The method getSingle() does not exist on Zemit\Mvc\Controller\Rest\Actions\GetAction. Did you maybe mean getSingleAction()? ( Ignorable by Annotation )

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

34
        /** @scrutinizer ignore-call */ 
35
        $entity = $this->getSingle($id);

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...
35
        
36
        if (!$entity) {
37
            return $this->setRestErrorResponse(404);
0 ignored issues
show
Bug introduced by
It seems like setRestErrorResponse() 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

37
            return $this->/** @scrutinizer ignore-call */ setRestErrorResponse(404);
Loading history...
38
        }
39
        
40
        $this->view->setVar('single', $this->expose($entity));
0 ignored issues
show
Bug introduced by
It seems like expose() 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

40
        $this->view->setVar('single', $this->/** @scrutinizer ignore-call */ expose($entity));
Loading history...
Bug introduced by
The property view does not exist on Zemit\Mvc\Controller\Rest\Actions\GetAction. Did you mean view;?
Loading history...
41
        return $this->setRestResponse(true);
0 ignored issues
show
Bug introduced by
It seems like setRestResponse() 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

41
        return $this->/** @scrutinizer ignore-call */ setRestResponse(true);
Loading history...
42
    }
43
    
44
}
45