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

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

08 May 2026 04:40AM UTC coverage: 24.082% (-1.2%) from 25.265%
25537160775

push

github

Enno Woortmann
Validate metadata on pre-existing MediaString pass-through; extract shared logic

When a MediaString or ImmutableMediaString instance is passed to a filter,
assert that its mediaType and encoding match the schema-declared values before
passing it through. Shared assertion logic extracted into AbstractMediaStringFilter.

0 of 31 new or added lines in 3 files covered. (0.0%)

1 existing line in 1 file now uncovered.

164 of 681 relevant lines covered (24.08%)

0.81 hits per line

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

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

3
declare(strict_types=1);
4

5
namespace PHPModelGenerator\Filter;
6

7
use InvalidArgumentException;
8

9
abstract class AbstractMediaStringFilter
10
{
11
    /**
12
     * @param array{mediaType?: string|null, encoding?: string|null} $options
13
     *
14
     * @throws InvalidArgumentException
15
     */
NEW
16
    protected static function assertMetadataMatch(
×
17
        ?string $actualMediaType,
18
        ?string $actualEncoding,
19
        array $options,
20
    ): void {
NEW
21
        $expectedMediaType = $options['mediaType'] ?? null;
×
NEW
22
        $expectedEncoding = $options['encoding'] ?? null;
×
23

NEW
24
        if ($actualMediaType !== $expectedMediaType) {
×
NEW
25
            throw new InvalidArgumentException(sprintf(
×
NEW
26
                'MediaString mediaType mismatch: expected %s, got %s',
×
NEW
27
                $expectedMediaType ?? 'null',
×
NEW
28
                $actualMediaType ?? 'null',
×
NEW
29
            ));
×
30
        }
31

NEW
32
        if ($actualEncoding !== $expectedEncoding) {
×
NEW
33
            throw new InvalidArgumentException(sprintf(
×
NEW
34
                'MediaString encoding mismatch: expected %s, got %s',
×
NEW
35
                $expectedEncoding ?? 'null',
×
NEW
36
                $actualEncoding ?? 'null',
×
NEW
37
            ));
×
38
        }
39
    }
40
}
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