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

codeigniter4 / CodeIgniter4 / 12739985319

13 Jan 2025 03:15AM UTC coverage: 84.486%. Remained the same
12739985319

push

github

paulbalandan
Merge branch 'develop' into 4.6

351 of 417 new or added lines in 121 files covered. (84.17%)

1 existing line in 1 file now uncovered.

20798 of 24617 relevant lines covered (84.49%)

189.94 hits per line

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

66.67
/system/Test/ConfigFromArrayTrait.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\Test;
15

16
use CodeIgniter\Exceptions\LogicException;
17

18
trait ConfigFromArrayTrait
19
{
20
    /**
21
     * Creates a Config instance from an array.
22
     *
23
     * @template T of \CodeIgniter\Config\BaseConfig
24
     *
25
     * @param class-string<T>      $classname Config classname
26
     * @param array<string, mixed> $config
27
     *
28
     * @return T
29
     */
30
    private function createConfigFromArray(string $classname, array $config)
31
    {
32
        $configObj = new $classname();
60✔
33

34
        foreach ($config as $key => $value) {
60✔
35
            if (property_exists($configObj, $key)) {
58✔
36
                $configObj->{$key} = $value;
58✔
37

38
                continue;
58✔
39
            }
40

41
            throw new LogicException(
×
NEW
42
                'No such property: ' . $classname . '::$' . $key,
×
43
            );
×
44
        }
45

46
        return $configObj;
60✔
47
    }
48
}
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

© 2025 Coveralls, Inc