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

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

02 Jul 2026 11:50PM UTC coverage: 21.548% (-0.7%) from 22.282%
28628908337

push

github

web-flow
Merge pull request #18 from wol-soft/feature/exception-json-pointer

Add JSON Pointer (RFC 6901) to all ValidationException subclasses

3 of 103 new or added lines in 37 files covered. (2.91%)

26 existing lines in 26 files now uncovered.

167 of 775 relevant lines covered (21.55%)

0.72 hits per line

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

0.0
/src/Exception/ComposedValue/ConditionalException.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace PHPModelGenerator\Exception\ComposedValue;
6

7
use Exception;
8
use PHPModelGenerator\Exception\ErrorRegistryExceptionInterface;
9
use PHPModelGenerator\Exception\ValidationException;
10

11
/**
12
 * Class ConditionalException
13
 *
14
 * @package PHPModelGenerator\Exception\ComposedValue
15
 */
16
class ConditionalException extends ValidationException
17
{
18
    /**
19
     * ConditionalException constructor.
20
     *
21
     * @param $providedValue
22
     */
23
    public function __construct(
×
24
        $providedValue,
25
        string $propertyName,
26
        string $jsonPointer,
27
        private readonly ?Exception $ifException,
28
        private readonly ?Exception $thenException,
29
        private readonly ?Exception $elseException
30
    ) {
31

NEW
32
        parent::__construct($this->getErrorMessage($propertyName), $propertyName, $providedValue, $jsonPointer);
×
33
    }
34

35
    public function getIfException(): ?Exception
×
36
    {
37
        return $this->ifException;
×
38
    }
39

40
    public function getThenException(): ?Exception
×
41
    {
42
        return $this->thenException;
×
43
    }
44

45
    public function getElseException(): ?Exception
×
46
    {
47
        return $this->elseException;
×
48
    }
49

50
    private function getErrorMessage(string $propertyName): string
×
51
    {
52
        $message = "Invalid value for $propertyName declined by conditional composition constraint\n";
×
53

54
        $message .= $this->ifException
×
55
            ? "  - Condition: Failed" . $this->getExceptionMessage($this->ifException)
×
56
            : '  - Condition: Valid';
×
57

58
        return $message . "\n  - Conditional branch failed:" .
×
59
            $this->getExceptionMessage($this->thenException ?: $this->elseException);
×
60
    }
61

62
    private function getExceptionMessage(Exception $exception): string
×
63
    {
64
        return $exception instanceof ErrorRegistryExceptionInterface
×
65
            ? implode(
×
NEW
66
                "\n    * ",
×
NEW
67
                array_map(
×
NEW
68
                    fn(ValidationException $exception): string => $exception->getMessage(),
×
NEW
69
                    $exception->getErrors(),
×
NEW
70
                ),
×
NEW
71
            )
×
UNCOV
72
            : "\n    * " . $exception->getMessage();
×
73
    }
74
}
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