-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPsrHeaderInput.php
More file actions
73 lines (64 loc) · 1.81 KB
/
PsrHeaderInput.php
File metadata and controls
73 lines (64 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php declare(strict_types=1);
/**
* Part of Windwalker project.
*
* @copyright Copyright (C) 2019 LYRASOFT.
* @license GNU General Public License version 2 or later.
*/
namespace Windwalker\IO;
use Windwalker\Http\Helper\HeaderHelper;
/**
* The HeaderInput class.
*
* @since 3.0
*/
class PsrHeaderInput extends Input
{
/**
* prepareSource
*
* @param array $source
* @param bool $reference
*
* @return void
*/
public function prepareSource(&$source = null, $reference = false)
{
$headers = [];
foreach ((array) $source as $key => $value) {
$headers[HeaderHelper::normalizeHeaderName($key)] = implode(', ', $value);
}
parent::prepareSource($headers, $reference);
}
/**
* Gets a value from the input data.
*
* @param string $name Name of the value to get.
* @param mixed $default Default value to return if variable does not exist.
* @param string $filter Filter to apply to the value.
* @param string $separator Separator for path.
*
* @return mixed The filtered input value.
*
* @since 2.0
*/
public function get($name, $default = null, $filter = 'cmd', $separator = '.')
{
$name = HeaderHelper::normalizeHeaderName(strtolower($name));
return parent::get($name, $default, $filter, $separator);
}
/**
* Sets a value
*
* @param string $name Name of the value to set.
* @param mixed $value Value to assign to the input.
* @param string $separator Symbol to separate path.
*
* @since 2.0
*/
public function set($name, $value, $separator = '.')
{
$name = HeaderHelper::normalizeHeaderName($name);
parent::set($name, $value, $separator);
}
}