Passed
Pull Request — master (#42)
by Korotkov
02:47
created

ContainerTrait::validation()   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
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author    : Jagepard <[email protected]">
7
 * @copyright Copyright (c) 2019, Jagepard
8
 * @license   https://mit-license.org/ MIT
9
 */
10
11
namespace Rudra\Container\Traits;
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
15
trait ContainerTrait
16
{
17
    /**
18
     * @return mixed
19
     */
20
    public function validation()
21
    {
22
        return rudra()->get('validation');
23
    }
24
25
    /**
26
     * @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...
27
     * @return mixed
28
     */
29
    public function redirect($target = null)
30
    {
31
        return isset($target) ? rudra()->get('redirect')->run($target) : rudra()->get('redirect');
32
    }
33
34
    /**
35
     * @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...
36
     * @return mixed
37
     */
38
    public function post($key = null)
39
    {
40
        return rudra()->request()->post()->get($key);
41
    }
42
43
    /**
44
     * @param      $object
45
     * @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...
46
     * @return mixed
47
     */
48
    public function new($object, $params = null)
49
    {
50
        return rudra()->new($object, $params);
51
    }
52
53
    /**
54
     * @param string      $key
55
     * @param string|null $subKey
56
     */
57
    public function unsetSession(string $key, string $subKey = null)
58
    {
59
        rudra()->session()->unset($key, $subKey);
60
    }
61
62
    /**
63
     * @return mixed
64
     */
65
    public function pagination()
66
    {
67
        return rudra()->get('pagination');
68
    }
69
70
    /**
71
     * @param $page
72
     * @param $perPage
73
     * @param $numRows
74
     */
75
    public function setPagination($page, $perPage, $numRows): void
76
    {
77
        rudra()->set('pagination', new Pagination($page['id'], $perPage, $numRows), 'raw');
78
    }
79
80
    /**
81
     * @param string      $key
82
     * @param string      $value
83
     * @param string|null $subKey
84
     */
85
    public function setSession(string $key, string $value, string $subKey = null): void
86
    {
87
        rudra()->session()->set($key, $value, $subKey);
88
    }
89
90
    /**
91
     * @return mixed
92
     */
93
    public function db()
94
    {
95
        return rudra()->get('db');
96
    }
97
}
98