Passed
Pull Request — master (#10)
by Korotkov
01:41
created

ContainerTrait::db()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author    : Korotkov Danila <[email protected]>
7
 * @copyright Copyright (c) 2018, Korotkov Danila
8
 * @license   http://www.gnu.org/licenses/gpl.html GNU GPLv3.0
9
 */
10
11
namespace Rudra\Traits;
12
13
use Rudra\Interfaces\ContainerInterface;
14
15
/**
16
 * Trait ContainerTrait
17
 * @package Rudra\Container\Traits
18
 */
19
trait ContainerTrait
20
{
21
22
    /**
23
     * @return mixed
24
     */
25
    public function validation()
26
    {
27
        return $this->container()->get('validation');
28
    }
29
30
    /**
31
     * @param null $target
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $target is correct as it would always require null to be passed?
Loading history...
32
     * @return mixed
33
     */
34
    public function redirect($target = null)
35
    {
36
        return isset($target) ? $this->container()->get('redirect')->run($target) : $this->container()->get('redirect');
37
    }
38
39
    /**
40
     * @param null $key
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $key is correct as it would always require null to be passed?
Loading history...
41
     * @return mixed
42
     */
43
    public function post($key = null)
44
    {
45
        return $this->container()->getPost($key);
0 ignored issues
show
Bug introduced by
The method getPost() does not exist on Rudra\Interfaces\ContainerInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Rudra\Interfaces\ContainerInterface. ( Ignorable by Annotation )

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

45
        return $this->container()->/** @scrutinizer ignore-call */ getPost($key);
Loading history...
46
    }
47
48
    /**
49
     * @param      $object
50
     * @param null $params
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $params is correct as it would always require null to be passed?
Loading history...
51
     * @return mixed
52
     */
53
    public function new($object, $params = null)
54
    {
55
        return $this->container()->new($object, $params);
56
    }
57
58
    /**
59
     * @param string      $key
60
     * @param string|null $subKey
61
     */
62
    public function unsetSession(string $key, string $subKey = null)
63
    {
64
        $this->container()->unsetSession($key, $subKey);
0 ignored issues
show
Bug introduced by
The method unsetSession() does not exist on Rudra\Interfaces\ContainerInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Rudra\Interfaces\ContainerInterface. ( Ignorable by Annotation )

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

64
        $this->container()->/** @scrutinizer ignore-call */ unsetSession($key, $subKey);
Loading history...
65
    }
66
67
    /**
68
     * @return mixed
69
     */
70
    public function pagination()
71
    {
72
        return $this->container()->get('pagination');
73
    }
74
75
    /**
76
     * @param $value
77
     */
78
    public function setPagination($value): void
79
    {
80
        $this->container()->set('pagination', new \Rudra\Pagination($value['id']), 'raw');
0 ignored issues
show
Bug introduced by
The type Rudra\Pagination was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
81
    }
82
83
84
    /**
85
     * @param string      $key
86
     * @param string      $value
87
     * @param string|null $subKey
88
     */
89
    public function setSession(string $key, string $value, string $subKey = null): void
90
    {
91
        $this->container()->setSession($key, $value, $subKey);
0 ignored issues
show
Bug introduced by
The method setSession() does not exist on Rudra\Interfaces\ContainerInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Rudra\Interfaces\ContainerInterface. ( Ignorable by Annotation )

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

91
        $this->container()->/** @scrutinizer ignore-call */ setSession($key, $value, $subKey);
Loading history...
92
    }
93
94
    /**
95
     * @return mixed
96
     */
97
    public function db()
98
    {
99
        return $this->container()->get('db');
100
    }
101
102
    /**
103
     * @return mixed
104
     */
105
    abstract public function container(): ContainerInterface;
106
}
107