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

dg / texy / 22262497275

21 Feb 2026 07:01PM UTC coverage: 93.057% (+0.7%) from 92.367%
22262497275

push

github

dg
added CLAUDE.md

2426 of 2607 relevant lines covered (93.06%)

0.93 hits per line

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

77.78
/src/Texy/HandlerInvocation.php
1
<?php declare(strict_types=1);
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
namespace Texy;
9

10
use function array_unshift, count, is_string;
11

12

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

20
        /** @var mixed[] */
21
        private array $args;
22

23

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

36

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

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

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

57
                return $res;
1✔
58
        }
59

60

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

66

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