• 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/MediaString.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace PHPModelGenerator\Filter;
6

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

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

NEW
36
        if ($value instanceof MediaStringValue || $value instanceof ImmutableMediaString) {
×
NEW
37
            self::assertMetadataMatch($value->getMediaType(), $value->getEncoding(), $options);
×
38

NEW
39
            if ($value instanceof MediaStringValue) {
×
NEW
40
                return $value;
×
41
            }
42

NEW
43
            return new MediaStringValue($value->getValue(), $options['mediaType'] ?? null, $options['encoding'] ?? null);
×
44
        }
45

NEW
46
        return new MediaStringValue($value, $options['mediaType'] ?? null, $options['encoding'] ?? null);
×
47
    }
48

49
    /**
50
     * Serialize a MediaString back to its raw string value.
51
     */
NEW
52
    public static function serialize(MediaStringValue|null $value): ?string
×
53
    {
NEW
54
        return $value !== null ? (string) $value : null;
×
55
    }
56
}
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