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

dg / texy / 21344532034

26 Jan 2026 02:43AM UTC coverage: 91.98% (-0.4%) from 92.376%
21344532034

push

github

dg
added CLAUDE.md

2397 of 2606 relevant lines covered (91.98%)

0.92 hits per line

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

77.78
/src/Texy/HandlerInvocation.php
1
<?php
2

3
/**
4
 * This file is part of the Texy! (https://texy.nette.org)
5
 * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6
 */
7

8
declare(strict_types=1);
9

10
namespace Texy;
11

12
use function array_unshift, count, is_string;
13

14

15
/**
16
 * Implements chain of responsibility for element handlers.
17
 */
18
final class HandlerInvocation
19
{
20
        private int $pos;
21

22
        /** @var mixed[] */
23
        private array $args;
24

25

26
        /** @param mixed[] $args */
27
        public function __construct(
1✔
28
                /** @var list<\Closure(mixed...): mixed> */
29
                private array $handlers,
30
                private readonly Parser $parser,
31
                array $args,
32
        ) {
33
                $this->pos = count($this->handlers);
1✔
34
                array_unshift($args, $this);
1✔
35
                $this->args = $args;
1✔
36
        }
1✔
37

38

39
        /**
40
         * Invokes next handler in chain, or throws if none remain.
41
         */
42
        public function proceed(mixed ...$args): string|HtmlElement|null
1✔
43
        {
44
                if ($this->pos === 0) {
1✔
45
                        throw new \RuntimeException('No more handlers.');
×
46
                }
47

48
                if ($args) {
1✔
49
                        $this->args = $args;
×
50
                        array_unshift($this->args, $this);
×
51
                }
52

53
                $this->pos--;
1✔
54
                $res = $this->handlers[$this->pos](...$this->args);
1✔
55
                if ($res !== null && !is_string($res) && !$res instanceof HtmlElement) {
1✔
56
                        throw new \UnexpectedValueException('Invalid value returned from handler.');
×
57
                }
58

59
                return $res;
1✔
60
        }
61

62

63
        public function getParser(): Parser
64
        {
65
                return $this->parser;
1✔
66
        }
67

68

69
        public function getTexy(): Texy
70
        {
71
                return $this->parser->getTexy();
1✔
72
        }
73
}
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