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

codeigniter4 / CodeIgniter4 / 28873713062

07 Jul 2026 02:23PM UTC coverage: 89.592% (+0.004%) from 89.588%
28873713062

Pull #10385

github

web-flow
Merge 226cf0160 into 18ee79cfa
Pull Request #10385: feat: add encrypted JSON casts

11 of 13 new or added lines in 2 files covered. (84.62%)

25291 of 28229 relevant lines covered (89.59%)

230.33 hits per line

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

75.0
/system/DataCaster/Cast/EncryptedJsonCast.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
use SensitiveParameter;
17
use stdClass;
18

19
/**
20
 * Class EncryptedJsonCast
21
 *
22
 * (PHP) [array|stdClass --> encrypted JSON string] --> (DB driver) --> (DB column) string
23
 *       [               <-- decrypted JSON string] <-- (DB driver) <-- (DB column) encrypted JSON string
24
 */
25
class EncryptedJsonCast extends BaseCast
26
{
27
    /**
28
     * @return array<array-key, mixed>|stdClass|null
29
     */
30
    public static function get(
31
        #[SensitiveParameter]
32
        mixed $value,
33
        array $params = [],
34
        ?object $helper = null,
35
    ): array|stdClass|null {
36
        if ($value === null) {
6✔
NEW
37
            return null;
×
38
        }
39

40
        $json = EncryptedCast::get($value, $params, $helper);
6✔
41

42
        return JsonCast::get($json, $params, $helper);
5✔
43
    }
44

45
    public static function set(
46
        #[SensitiveParameter]
47
        mixed $value,
48
        array $params = [],
49
        ?object $helper = null,
50
    ): ?string {
51
        if ($value === null) {
4✔
NEW
52
            return null;
×
53
        }
54

55
        $json = JsonCast::set($value, $params, $helper);
4✔
56

57
        return EncryptedCast::set($json, $params, $helper);
4✔
58
    }
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc