Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
/*
6
 * This file is part of the league/commonmark package.
7
 *
8
 * (c) Colin O'Dell <colinodell@gmail.com>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
 
14
namespace League\CommonMark\Node\Query;
15
 
16
use League\CommonMark\Node\Node;
17
 
18
/**
19
 * @internal
20
 */
21
final class AndExpr implements ExpressionInterface
22
{
23
    /**
24
     * @var callable[]
25
     * @psalm-var list<callable(Node): bool>
26
     */
27
    private array $conditions;
28
 
29
    /**
30
     * @psalm-param callable(Node): bool $expressions
31
     */
32
    public function __construct(callable ...$expressions)
33
    {
621 lars 34
        $this->conditions = \array_values($expressions);
148 lars 35
    }
36
 
37
    /**
38
     * @param callable(Node): bool $expression
39
     */
40
    public function add(callable $expression): void
41
    {
42
        $this->conditions[] = $expression;
43
    }
44
 
45
    public function __invoke(Node $node): bool
46
    {
47
        foreach ($this->conditions as $condition) {
48
            if (! $condition($node)) {
49
                return false;
50
            }
51
        }
52
 
53
        return true;
54
    }
55
}