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

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

19 Sep 2025 03:15PM UTC coverage: 18.962% (+5.0%) from 13.926%
17862408584

push

github

web-flow
Merge pull request #12 from wol-soft/BuilderClassPostProcessor

BuilderInterface

3 of 3 new or added lines in 1 file covered. (100.0%)

99 existing lines in 36 files now uncovered.

106 of 559 relevant lines covered (18.96%)

0.55 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
    /** @var Exception|null */
19
    private $ifException;
20
    /** @var Exception|null */
21
    private $thenException;
22
    /** @var Exception|null */
23
    private $elseException;
24

25
    /**
26
     * ConditionalException constructor.
27
     *
28
     * @param $providedValue
29
     * @param string $propertyName
30
     * @param Exception|null $ifException
31
     * @param Exception|null $thenException
32
     * @param Exception|null $elseException
33
     */
UNCOV
34
    public function __construct(
×
35
        $providedValue,
36
        string $propertyName,
37
        ?Exception $ifException,
38
        ?Exception $thenException,
39
        ?Exception $elseException
40
    ) {
41

42
        // ,
43
        $this->ifException = $ifException;
×
44
        $this->thenException = $thenException;
×
45
        $this->elseException = $elseException;
×
46

47
        parent::__construct($this->getErrorMessage($propertyName), $propertyName, $providedValue);
×
48
    }
49

50
    /**
51
     * @return Exception|null
52
     */
UNCOV
53
    public function getIfException(): ?Exception
×
54
    {
55
        return $this->ifException;
×
56
    }
57

58
    /**
59
     * @return Exception|null
60
     */
UNCOV
61
    public function getThenException(): ?Exception
×
62
    {
63
        return $this->thenException;
×
64
    }
65

66
    /**
67
     * @return Exception|null
68
     */
UNCOV
69
    public function getElseException(): ?Exception
×
70
    {
71
        return $this->elseException;
×
72
    }
73

UNCOV
74
    private function getErrorMessage(string $propertyName): string
×
75
    {
76
        $message = "Invalid value for $propertyName declined by conditional composition constraint\n";
×
77

78
        $message .= $this->ifException
×
79
            ? "  - Condition: Failed" . $this->getExceptionMessage($this->ifException)
×
80
            :'  - Condition: Valid';
×
81

82
        return $message . "\n  - Conditional branch failed:" .
×
83
            $this->getExceptionMessage($this->thenException ?: $this->elseException);
×
84
    }
85

UNCOV
86
    private function getExceptionMessage(Exception $exception): string
×
87
    {
88
        return $exception instanceof ErrorRegistryExceptionInterface
×
89
            ? implode(
×
90
                    "\n    * ",
×
UNCOV
91
                    array_map(function (ValidationException $exception): string {
×
92
                        return $exception->getMessage();
×
93
                    }, $exception->getErrors())
×
94
                )
×
95
            : "\n    * " . $exception->getMessage();
×
96
    }
97
}
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