• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

codeigniter4 / CodeIgniter4 / 13752492474

09 Mar 2025 09:04PM UTC coverage: 84.497% (-0.02%) from 84.512%
13752492474

Pull #9482

github

web-flow
Merge e1da19c32 into b1f2bee6b
Pull Request #9482: feat: Improve `Superglobals` service

19 of 27 new or added lines in 2 files covered. (70.37%)

20864 of 24692 relevant lines covered (84.5%)

190.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.23
/system/HTTP/Parameters/InputParameters.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of CodeIgniter 4 framework.
7
 *
8
 * (c) CodeIgniter Foundation <admin@codeigniter.com>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace CodeIgniter\HTTP\Parameters;
15

16
use CodeIgniter\Exceptions\InvalidArgumentException;
17
use CodeIgniter\Exceptions\RuntimeException;
18

19
/**
20
 * @template TKey of string
21
 * @template TValue of bool|float|int|string|array<int|string, mixed>
22
 *
23
 * @see \CodeIgniter\HTTP\Parameters\InputParametersTest
24
 */
25
class InputParameters extends Parameters
26
{
27
    public function override(array $parameters = []): void
28
    {
NEW
29
        $this->parameters = [];
×
30

NEW
31
        foreach ($parameters as $key => $value) {
×
NEW
32
            $this->set($key, $value);
×
33
        }
34
    }
35

36
    public function get(string $key, $default = null)
37
    {
38
        if ($default !== null && ! is_scalar($default)) {
1✔
39
            throw new InvalidArgumentException(sprintf('The default value for the InputParameters must be a scalar type, "%s" given.', gettype($default)));
1✔
40
        }
41

42
        // TODO: We need to check that the default value is set. Let's check the unique string
43
        $tempDefault = bin2hex(random_bytes(8));
1✔
44

45
        $value = parent::get($key, $tempDefault);
1✔
46

47
        if ($value !== null && $value !== $tempDefault && ! is_scalar($value)) {
1✔
NEW
48
            throw new RuntimeException(sprintf('The value of the key "%s" InputParameters does not contain a scalar value, "%s" given.', $key, gettype($value)));
×
49
        }
50

51
        return $value === $tempDefault ? $default : $value;
1✔
52
    }
53

54
    public function set(string $key, $value): void
55
    {
56
        if (! is_scalar($value) && ! is_array($value)) {
3✔
57
            throw new InvalidArgumentException(sprintf('The value for the InputParameters must be a scalar type, "%s" given.', gettype($value)));
2✔
58
        }
59

60
        $this->parameters[$key] = $value;
1✔
61
    }
62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc