graph-tools-php

Форк
0
/
ConstTraverseFilter.php 
58 строк · 1.9 Кб
1
<?php
2

3
namespace Smoren\GraphTools\Filters;
4

5
use Smoren\GraphTools\Conditions\FilterCondition;
6
use Smoren\GraphTools\Conditions\Interfaces\FilterConditionInterface;
7
use Smoren\GraphTools\Conditions\Interfaces\VertexConditionInterface;
8
use Smoren\GraphTools\Conditions\VertexCondition;
9
use Smoren\GraphTools\Filters\Interfaces\TraverseFilterInterface;
10
use Smoren\GraphTools\Structs\Interfaces\TraverseContextInterface;
11

12
/**
13
 * Constant traverse filter
14
 * @author Smoren <ofigate@gmail.com>
15
 */
16
class ConstTraverseFilter extends ConfigurableTraverseFilter implements TraverseFilterInterface
17
{
18
    /**
19
     * @var FilterConditionInterface|FilterCondition condition of next traverse behavior
20
     */
21
    protected FilterConditionInterface $passCondition;
22
    /**
23
     * @var VertexConditionInterface|VertexCondition condition of current vertex handling
24
     */
25
    protected VertexConditionInterface $handleCondition;
26

27
    /**
28
     * ConstTraverseFilter constructor
29
     * @param FilterConditionInterface|null $passCondition condition of next traverse behavior
30
     * @param VertexConditionInterface|null $handleCondition condition of current vertex handling
31
     * @param array<int> $config filter config
32
     */
33
    public function __construct(
34
        ?FilterConditionInterface $passCondition = null,
35
        ?VertexConditionInterface $handleCondition = null,
36
        array $config = []
37
    ) {
38
        parent::__construct($config);
39
        $this->passCondition = $passCondition ?? new FilterCondition();
40
        $this->handleCondition = $handleCondition ?? new VertexCondition();
41
    }
42

43
    /**
44
     * @inheritDoc
45
     */
46
    protected function getDefaultPassCondition(TraverseContextInterface $context): FilterConditionInterface
47
    {
48
        return $this->passCondition;
49
    }
50

51
    /**
52
     * @inheritDoc
53
     */
54
    protected function getDefaultHandleCondition(TraverseContextInterface $context): VertexConditionInterface
55
    {
56
        return $this->handleCondition;
57
    }
58
}
59

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.