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

3
declare(strict_types = 1);
4

5
namespace PHPModelGenerator\Exception\ComposedValue;
6

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

10
/**
11
 * Class InvalidComposedValueException
12
 *
13
 * @package PHPModelGenerator\Exception\ComposedValue
14
 */
15
abstract class InvalidComposedValueException extends ValidationException
16
{
17
    protected const COMPOSED_ERROR_MESSAGE = '';
18

19
    /** @var int */
20
    protected $succeededCompositionElements;
21
    /** @var ValidationException[][] */
22
    protected $compositionErrorCollection;
23
    /**
24
     * InvalidComposedValueException constructor.
25
     *
26
     * @param $providedValue
27
     * @param string $propertyName
28
     * @param int $succeededCompositionElements
29
     * @param ValidationException[][] $compositionErrorCollection
30
     */
UNCOV
31
    public function __construct(
×
32
        $providedValue,
33
        string $propertyName,
34
        int $succeededCompositionElements,
35
        array $compositionErrorCollection
36
    ) {
37
        $this->succeededCompositionElements = $succeededCompositionElements;
×
38
        $this->compositionErrorCollection = $compositionErrorCollection;
×
39

40
        parent::__construct($this->getErrorMessage($propertyName), $propertyName, $providedValue);
×
41
    }
42

43
    /**
44
     * @return int
45
     */
UNCOV
46
    public function getSucceededCompositionElements(): int
×
47
    {
48
        return $this->succeededCompositionElements;
×
49
    }
50

51
    /**
52
     * @return ValidationException[][]
53
     */
UNCOV
54
    public function getCompositionErrorCollection(): array
×
55
    {
56
        return $this->compositionErrorCollection;
×
57
    }
58

UNCOV
59
    protected function getErrorMessage(string $propertyName): string
×
60
    {
61
        $compositionIndex = 0;
×
62

63
        return "Invalid value for $propertyName declined by composition constraint.\n  " .
×
64
            sprintf(static::COMPOSED_ERROR_MESSAGE, $this->succeededCompositionElements) .
×
65
            array_reduce(
×
66
                $this->compositionErrorCollection,
×
UNCOV
67
                function (string $carry, ErrorRegistryExceptionInterface $exception) use (&$compositionIndex): string {
×
68
                    return "$carry\n  - Composition element #" . ++$compositionIndex . (
×
69
                        $exception->getErrors()
×
70
                            ? ": Failed\n    * " .
×
71
                                implode(
×
72
                                    "\n    * ",
×
UNCOV
73
                                    array_map(function (ValidationException $exception): string {
×
74
                                        return $exception->getMessage();
×
75
                                    }, $exception->getErrors())
×
76
                                )
×
77
                            : ': Valid'
×
78
                        );
×
79
                },
×
80
                ''
×
81
            );
×
82
    }
83
}
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