| Conditions | 9 |
| Paths | 64 |
| Total Lines | 19 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 90 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | public static function forTagWithParent(string $tagName, ?string $attrName = null, ?string $parent = null, bool $first = false, bool $void = false, bool $voidAttr = false): self |
||
| 23 | { |
||
| 24 | $errorMessage = 'Tag "%s" ' . (!empty($parent) ? ('must be inside a tag with attribute "%s"' . ($first ? ' as the first' : '')) : ('' === $parent ? $parent : 'is unexpected here')); |
||
|
|
|||
| 25 | $errorArgs = [$tagName]; |
||
| 26 | |||
| 27 | if (null !== $attrName) { |
||
| 28 | $errorMessage = \substr_replace($errorMessage, ' with attribute "%s"' . ($voidAttr ? ' expected no value' . (!empty($parent) ? ', and ' : ' ') : ' '), 8, 1); |
||
| 29 | $errorArgs[] = $attrName; |
||
| 30 | } |
||
| 31 | |||
| 32 | if ($void) { |
||
| 33 | $errorMessage .= ' and must be self closed.'; |
||
| 34 | } |
||
| 35 | |||
| 36 | if (null !== $parent) { |
||
| 37 | $errorArgs[] = $parent; |
||
| 38 | } |
||
| 39 | |||
| 40 | return new self(\vsprintf($errorMessage, $errorArgs)); |
||
| 41 | } |
||
| 43 |