Passed
Push — master ( f56acd...480a35 )
by Korotkov
02:59 queued 10s
created

ContainerTrait::post()   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 1
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\ExternalTraits;
12
13
use Rudra\Pagination;
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...
14
use Rudra\ContainerInterface;
15
16
/**
17
 * Trait ContainerTrait
18
 * @package Rudra\Container\Traits
19
 */
20
trait ContainerTrait
21
{
22
23
    /**
24
     * @return mixed
25
     */
26
    public function validation()
27
    {
28
        return $this->container()->get('validation');
29
    }
30
31
    /**
32
     * @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...
33
     * @return mixed
34
     */
35
    public function redirect($target = null)
36
    {
37
        return isset($target) ? $this->container()->get('redirect')->run($target) : $this->container()->get('redirect');
38
    }
39
40
    /**
41
     * @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...
42
     * @return mixed
43
     */
44
    public function post($key = null)
45
    {
46
        return $this->container()->getPost($key);
47
    }
48
49
    /**
50
     * @param      $object
51
     * @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...
52
     * @return mixed
53
     */
54
    public function new($object, $params = null)
55
    {
56
        return $this->container()->new($object, $params);
57
    }
58
59
    /**
60
     * @param string      $key
61
     * @param string|null $subKey
62
     */
63
    public function unsetSession(string $key, string $subKey = null)
64
    {
65
        $this->container()->unsetSession($key, $subKey);
66
    }
67
68
    /**
69
     * @return mixed
70
     */
71
    public function pagination()
72
    {
73
        return $this->container()->get('pagination');
74
    }
75
76
    /**
77
     * @param $value
78
     */
79
    public function setPagination($value): void
80
    {
81
        $this->container()->set('pagination', new Pagination($value['id']), 'raw');
82
    }
83
84
85
    /**
86
     * @param string      $key
87
     * @param string      $value
88
     * @param string|null $subKey
89
     */
90
    public function setSession(string $key, string $value, string $subKey = null): void
91
    {
92
        $this->container()->setSession($key, $value, $subKey);
93
    }
94
95
    /**
96
     * @return mixed
97
     */
98
    public function db()
99
    {
100
        return $this->container()->get('db');
101
    }
102
103
    /**
104
     * @return mixed
105
     */
106
    abstract public function container(): ContainerInterface;
107
}
108