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

wol-soft / php-json-schema-model-generator-production / 25722874106

12 May 2026 08:29AM UTC coverage: 23.529% (+0.3%) from 23.276%
25722874106

Pull #14

github

web-flow
Merge cdd636bac into 76710d87f
Pull Request #14: Json schema draft7

32 of 123 new or added lines in 15 files covered. (26.02%)

1 existing line in 1 file now uncovered.

164 of 697 relevant lines covered (23.53%)

0.79 hits per line

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

0.0
/src/Filter/ImmutableMediaString.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace PHPModelGenerator\Filter;
6

7
use InvalidArgumentException;
8
use PHPModelGenerator\ValueObject\ImmutableMediaString as ImmutableMediaStringValue;
9
use PHPModelGenerator\ValueObject\MediaString;
10

11
class ImmutableMediaString extends AbstractMediaStringFilter
12
{
13
    /**
14
     * Wrap a raw string in an ImmutableMediaString carrying the schema-defined media type and
15
     * encoding.
16
     *
17
     * Pass-through rules:
18
     *   - null                 → null (nullable property)
19
     *   - ImmutableMediaString → returned unchanged after validating mediaType/encoding match
20
     *   - MediaString          → converted to ImmutableMediaString after validating mediaType/encoding match
21
     *   - string               → wrapped with mediaType / encoding from $options
22
     *
23
     * @param string|MediaString|ImmutableMediaStringValue|null $value
24
     * @param array{mediaType?: string|null, encoding?: string|null} $options
25
     *
26
     * @throws InvalidArgumentException when a pre-existing wrapper's mediaType or encoding
27
     *                                  does not match the schema-declared values
28
     */
NEW
29
    public static function filter(
×
30
        string|MediaString|ImmutableMediaStringValue|null $value,
31
        array $options = [],
32
    ): ?ImmutableMediaStringValue {
NEW
33
        if ($value === null) {
×
NEW
34
            return null;
×
35
        }
36

NEW
37
        if ($value instanceof ImmutableMediaStringValue || $value instanceof MediaString) {
×
NEW
38
            self::assertMetadataMatch($value->getMediaType(), $value->getEncoding(), $options);
×
39

NEW
40
            if ($value instanceof ImmutableMediaStringValue) {
×
NEW
41
                return $value;
×
42
            }
43

NEW
44
            return new ImmutableMediaStringValue(
×
NEW
45
                $value->getValue(),
×
NEW
46
                $options['mediaType'] ?? null,
×
NEW
47
                $options['encoding'] ?? null,
×
NEW
48
            );
×
49
        }
50

NEW
51
        return new ImmutableMediaStringValue(
×
NEW
52
            $value,
×
NEW
53
            $options['mediaType'] ?? null,
×
NEW
54
            $options['encoding'] ?? null,
×
NEW
55
        );
×
56
    }
57

58
    /**
59
     * Serialize an ImmutableMediaString back to its raw string value.
60
     */
NEW
61
    public static function serialize(ImmutableMediaStringValue|null $value): ?string
×
62
    {
NEW
63
        return $value !== null ? (string) $value : null;
×
64
    }
65
}
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