X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fbehat%2Fbehat%2Fsrc%2FBehat%2FTestwork%2FArgument%2FPregMatchArgumentOrganiser.php;fp=vendor%2Fbehat%2Fbehat%2Fsrc%2FBehat%2FTestwork%2FArgument%2FPregMatchArgumentOrganiser.php;h=0000000000000000000000000000000000000000;hp=2fb05358522ce563449eaa4a80bdd6475b4ee0e2;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/behat/behat/src/Behat/Testwork/Argument/PregMatchArgumentOrganiser.php b/vendor/behat/behat/src/Behat/Testwork/Argument/PregMatchArgumentOrganiser.php deleted file mode 100644 index 2fb053585..000000000 --- a/vendor/behat/behat/src/Behat/Testwork/Argument/PregMatchArgumentOrganiser.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Behat\Testwork\Argument; - -use ReflectionFunctionAbstract; - -/** - * Organises arguments coming from preg_match results. - * - * @author Konstantin Kudryashov - */ -final class PregMatchArgumentOrganiser implements ArgumentOrganiser -{ - /** - * @var ArgumentOrganiser - */ - private $baseOrganiser; - - /** - * Initialises organiser. - * - * @param ArgumentOrganiser $organiser - */ - public function __construct(ArgumentOrganiser $organiser) - { - $this->baseOrganiser = $organiser; - } - - /** - * {@inheritdoc} - */ - public function organiseArguments(ReflectionFunctionAbstract $function, array $match) - { - $arguments = $this->cleanupMatchDuplicates($match); - - return $this->baseOrganiser->organiseArguments($function, $arguments); - } - - /** - * Cleans up provided preg_match match into a list of arguments. - * - * `preg_match` matches named arguments with named indexes and also - * represents all arguments with numbered indexes. This method removes - * duplication and also drops the first full match element from the - * array. - * - * @param array $match - * - * @return mixed[] - */ - private function cleanupMatchDuplicates(array $match) - { - $cleanMatch = array_slice($match, 1); - $arguments = array(); - - $keys = array_keys($cleanMatch); - for ($keyIndex = 0; $keyIndex < count($keys); $keyIndex++) { - $key = $keys[$keyIndex]; - - $arguments[$key] = $cleanMatch[$key]; - - if ($this->isKeyAStringAndNexOneIsAnInteger($keyIndex, $keys)) { - $keyIndex += 1; - } - } - - return $arguments; - } - - /** - * Checks if key at provided index is a string and next key in the array is an integer. - * - * @param integer $keyIndex - * @param mixed[] $keys - * - * @return Boolean - */ - private function isKeyAStringAndNexOneIsAnInteger($keyIndex, array $keys) - { - $keyIsAString = is_string($keys[$keyIndex]); - $nextKeyIsAnInteger = isset($keys[$keyIndex + 1]) && is_integer($keys[$keyIndex + 1]); - - return $keyIsAString && $nextKeyIsAnInteger; - } -}