Basic::inputRawPaths()   A
last analyzed

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
namespace kalanis\kw_input\Sources;
4
5
6
use kalanis\kw_input\Interfaces;
7
use kalanis\kw_input\Parsers;
8
9
10
/**
11
 * Class Basic
12
 * @package kalanis\kw_input\Sources
13
 * Source of values to parse and use
14
 * @codeCoverageIgnore because this is access to php internals
15
 */
16
class Basic implements Interfaces\ISource
17
{
18
    /** @var string[]|int[]|array<string|int, string|int|bool> */
19
    protected array $cliArgs = [];
20
    /** @var string[]|int[]|array<string|int, string|int|bool> */
21
    protected array $externalArgs = [];
22
23
    /**
24
     * @param array<string|int, string|int> $cliArgs
25
     * @return $this
26
     */
27
    public function setCli(array $cliArgs = []): self
28
    {
29
        $this->cliArgs = $cliArgs;
30
        return $this;
31
    }
32
33
    public function cli(): ?array
34
    {
35
        return $this->cliArgs;
36
    }
37
38
    public function get(): ?array
39
    {
40
        return $_GET;
41
    }
42
43
    public function post(): ?array
44
    {
45
        return $_POST;
46
    }
47
48
    public function files(): ?array
49
    {
50
        return $_FILES;
51
    }
52
53
    public function cookie(): ?array
54
    {
55
        return $_COOKIE;
56
    }
57
58
    public function session(): ?array
59
    {
60
        return PHP_SESSION_ACTIVE == session_status() ? $_SESSION : [];
61
    }
62
63
    public function server(): ?array
64
    {
65
        return $_SERVER ? Parsers\FixServer::updateAuth(Parsers\FixServer::updateVars($_SERVER)) : null;
66
    }
67
68
    public function env(): ?array
69
    {
70
        return $_ENV;
71
    }
72
73
    public function external(): ?array
74
    {
75
        return $this->externalArgs;
76
    }
77
78
    public function inputRawPaths(): ?array
79
    {
80
        return ['php://input'];
81
    }
82
83
    /**
84
     * @param string[]|int[]|array<string|int, string|int|bool> $externalArgs
85
     * @return $this
86
     */
87
    public function setExternal(array $externalArgs = []): self
88
    {
89
        $this->externalArgs = $externalArgs;
90
        return $this;
91
    }
92
}
93