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

codeigniter4 / CodeIgniter4 / 8586246081

07 Apr 2024 04:43AM UTC coverage: 86.602% (+1.0%) from 85.607%
8586246081

push

github

web-flow
Merge pull request #8720 from codeigniter4/4.5

Merge 4.5 into develop

2273 of 2603 new or added lines in 188 files covered. (87.32%)

53 existing lines in 18 files now uncovered.

19947 of 23033 relevant lines covered (86.6%)

189.35 hits per line

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

83.33
/system/DataCaster/Cast/ArrayCast.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\DataCaster\Cast;
15

16
/**
17
 * Class ArrayCast
18
 *
19
 * (PHP) [array --> string] --> (DB driver) --> (DB column) string
20
 *       [      <-- string] <-- (DB driver) <-- (DB column) string
21
 */
22
class ArrayCast extends BaseCast implements CastInterface
23
{
24
    public static function get(
25
        mixed $value,
26
        array $params = [],
27
        ?object $helper = null
28
    ): array {
29
        if (! is_string($value)) {
1✔
NEW
30
            self::invalidTypeValueError($value);
×
31
        }
32

33
        if ((str_starts_with($value, 'a:') || str_starts_with($value, 's:'))) {
1✔
34
            $value = unserialize($value, ['allowed_classes' => false]);
1✔
35
        }
36

37
        return (array) $value;
1✔
38
    }
39

40
    public static function set(
41
        mixed $value,
42
        array $params = [],
43
        ?object $helper = null
44
    ): string {
45
        return serialize($value);
1✔
46
    }
47
}
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