Passed
Pull Request — master (#53)
by Korotkov
01:43
created

ContainerTrait::new()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author    : Jagepard <[email protected]">
7
 * @license   https://mit-license.org/ MIT
8
 */
9
10
namespace Rudra\Container\Traits;
11
12
trait ContainerTrait
13
{
14
    public function db()
15
    {
16
        return rudra()->di()->get("db");
17
    }
18
19
    public function validation()
20
    {
21
        return rudra()->di()->get("validation");
22
    }
23
24
    public function redirect(string $target = null)
25
    {
26
        return isset($target) ? rudra()->di()->get("redirect")->run($target) : rudra()->di()->get("redirect");
27
    }
28
29
    public function post($key = null)
30
    {
31
        return rudra()->request()->post()->get($key);
32
    }
33
34
    public function setSession(string $key, string $value): void
35
    {
36
        rudra()->session()->set([$key, $value]);
37
    }
38
39
    public function unsetSession(string $key, string $subKey = null)
40
    {
41
        rudra()->session()->unset($key, $subKey);
0 ignored issues
show
Bug introduced by
The method unset() does not exist on Rudra\Container\Interfaces\ContainerInterface. It seems like you code against a sub-type of Rudra\Container\Interfaces\ContainerInterface such as Rudra\Container\Cookie or Rudra\Container\Session. ( Ignorable by Annotation )

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

41
        rudra()->session()->/** @scrutinizer ignore-call */ unset($key, $subKey);
Loading history...
42
    }
43
}
44