Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Context / Snippet / Generator / AggregateContextIdentifier.php
1 <?php
2
3 /*
4  * This file is part of the Behat.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 namespace Behat\Behat\Context\Snippet\Generator;
12
13 use Behat\Behat\Context\Environment\ContextEnvironment;
14
15 /**
16  * Uses multiple child identifiers - the first one that returns non-null result would
17  * be the winner.
18  *
19  * This behaviour was introduced in 3.x to support the BC for interface-focused
20  * context identifier, while providing better user experience (no need to explicitly
21  * call `--snippets-for` on `--append-snippets` when contexts do not implement any
22  * snippet accepting interfaces).
23  */
24 final class AggregateContextIdentifier implements TargetContextIdentifier
25 {
26     /**
27      * @var TargetContextIdentifier[]
28      */
29     private $identifiers;
30
31     /**
32      * Initialises identifier.
33      *
34      * @param TargetContextIdentifier[] $identifiers
35      */
36     public function __construct(array $identifiers)
37     {
38         $this->identifiers = $identifiers;
39     }
40
41     /**
42      * {@inheritdoc}
43      */
44     public function guessTargetContextClass(ContextEnvironment $environment)
45     {
46         foreach ($this->identifiers as $identifier) {
47             $contextClass = $identifier->guessTargetContextClass($environment);
48
49             if (null !== $contextClass) {
50                 return $contextClass;
51             }
52         }
53
54         return null;
55     }
56 }