4 * This file is part of the Behat.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Behat\Context\Snippet\Generator;
13 use Behat\Behat\Context\Environment\ContextEnvironment;
16 * Uses multiple child identifiers - the first one that returns non-null result would
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).
24 final class AggregateContextIdentifier implements TargetContextIdentifier
27 * @var TargetContextIdentifier[]
32 * Initialises identifier.
34 * @param TargetContextIdentifier[] $identifiers
36 public function __construct(array $identifiers)
38 $this->identifiers = $identifiers;
44 public function guessTargetContextClass(ContextEnvironment $environment)
46 foreach ($this->identifiers as $identifier) {
47 $contextClass = $identifier->guessTargetContextClass($environment);
49 if (null !== $contextClass) {