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

wol-soft / php-json-schema-model-generator / 14407937636

11 Apr 2025 04:41PM UTC coverage: 98.813%. Remained the same
14407937636

Pull #88

github

web-flow
Merge 7dcf4b3f6 into 8823c7c14
Pull Request #88: Fix code typo in README

2914 of 2949 relevant lines covered (98.81%)

517.53 hits per line

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

93.75
/src/Model/Validator/MultiTypeCheckValidator.php
1
<?php
2

3
declare(strict_types = 1);
4

5
namespace PHPModelGenerator\Model\Validator;
6

7
use PHPModelGenerator\Exception\Generic\InvalidTypeException;
8
use PHPModelGenerator\Model\Property\PropertyInterface;
9

10
/**
11
 * Class MultiTypeCheckValidator
12
 *
13
 * @package PHPModelGenerator\Model\Validator
14
 */
15
class MultiTypeCheckValidator extends PropertyValidator implements TypeCheckInterface
16
{
17
    /**
18
     * MultiTypeCheckValidator constructor.
19
     *
20
     * @param string[]          $types
21
     */
22
    public function __construct(protected array $types, PropertyInterface $property, bool $allowImplicitNull)
23
    {
24
        // if null is explicitly allowed we don't need an implicit null pass through
25
        if (in_array('null', $this->types)) {
59✔
26
            $allowImplicitNull = false;
15✔
27
        }
28

29
        parent::__construct(
59✔
30
            $property,
59✔
31
            join(
59✔
32
                ' && ',
59✔
33
                array_map(
59✔
34
                    static fn(string $allowedType): string =>
59✔
35
                        ReflectionTypeCheckValidator::fromType($allowedType, $property)->getCheck(),
59✔
36
                    $this->types,
59✔
37
                )
59✔
38
            ) . ($allowImplicitNull ? ' && $value !== null' : ''),
59✔
39
            InvalidTypeException::class,
59✔
40
            [$this->types],
59✔
41
        );
59✔
42
    }
43

44
    /**
45
     * @inheritDoc
46
     */
47
    public function getTypes(): array
48
    {
49
        return $this->types;
×
50
    }
51
}
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

© 2025 Coveralls, Inc