Issues (105)

src/Route/Traits/HasRequestTrait.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace Nip\Router\Route\Traits;
4
5
/**
6
 * Trait HasRequestTrait
7
 * @package Nip\Router\Route\Traits
8
 */
9
trait HasRequestTrait
10
{
11
    protected $request = null;
12
13
    public function populateRequest()
14
    {
15
        $params = $this->getParams();
0 ignored issues
show
It seems like getParams() 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

15
        /** @scrutinizer ignore-call */ 
16
        $params = $this->getParams();
Loading history...
16
        foreach ($params as $param => $value) {
17
            switch ($param) {
18
                case 'module':
19
                    $this->getRequest()->setModuleName($value);
20
                    break;
21
                case 'controller':
22
                    $this->getRequest()->setControllerName($value);
23
                    break;
24
                case 'action':
25
                    $this->getRequest()->setActionName($value);
26
                    break;
27
                default:
28
                    $this->getRequest()->attributes->set($param, $value);
29
                    break;
30
            }
31
        }
32
        $this->getRequest()->attributes->add($this->getMatches());
0 ignored issues
show
It seems like getMatches() 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

32
        $this->getRequest()->attributes->add($this->/** @scrutinizer ignore-call */ getMatches());
Loading history...
33
    }
34
35
    /**
36
     * @return \Nip\Request
37
     */
38
    public function getRequest()
39
    {
40
        return $this->request;
41
    }
42
43
    /**
44
     * @param \Nip\Request $request
45
     */
46
    public function setRequest($request)
47
    {
48
        $this->request = $request;
49
    }
50
}
51