|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/irtiweb/CATS/vendor/behat/behat/src/Behat/Behat/Snippet/ |
Upload File : |
<?php
/*
* This file is part of the Behat.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Behat\Snippet;
use Behat\Gherkin\Node\StepNode;
/**
* Aggregates multiple similar snippets with different targets and steps.
*
* @author Konstantin Kudryashov <[email protected]>
*/
final class AggregateSnippet
{
/**
* @var Snippet[]
*/
private $snippets;
/**
* Initializes snippet.
*
* @param Snippet[] $snippets
*/
public function __construct(array $snippets)
{
$this->snippets = $snippets;
}
/**
* Returns snippet type.
*
* @return string
*/
public function getType()
{
return current($this->snippets)->getType();
}
/**
* Returns snippet unique ID (step type independent).
*
* @return string
*/
public function getHash()
{
return current($this->snippets)->getHash();
}
/**
* Returns definition snippet text.
*
* @return string
*/
public function getSnippet()
{
return current($this->snippets)->getSnippet();
}
/**
* Returns all steps interested in this snippet.
*
* @return StepNode[]
*/
public function getSteps()
{
return array_unique(
array_map(
function (Snippet $snippet) {
return $snippet->getStep();
},
$this->snippets
),
SORT_REGULAR
);
}
/**
* Returns all snippet targets.
*
* @return string[]
*/
public function getTargets()
{
return array_unique(
array_map(
function (Snippet $snippet) {
return $snippet->getTarget();
},
$this->snippets
)
);
}
}