@param array           $property
@param AbstractCommand $command

@return array
549194
private function filterForCommand(array $property, AbstractCommand $command)
    {
        $filtered = [];
        foreach ($property as $commandClassName => $handler) {
            if ($command instanceof $commandClassName) {
                // After that, we still need to check if there is no other handler defined for this command.
                // This is because we allow command handler to listen to parent class or interface.
                $filtered[] = $handler;
            }
        }

        return $filtered;
    }
358272
public function pluck($array, $property, &$return = false)
    {
        $return = [];

        if (count($array) > 0) {
            foreach ($array as $item) {
                if (is_array($item)) {
                    $this->pluck($array, $property, $return);
                }

                $return[] = $item->$property;
            }
        }

        return $return;
    }
116431
protected function getKeyFromBlockingListCommands(CommandInterface $command)
    {
        $arguments = $command->getArguments();

        if ($this->checkSameSlotForKeys(array_slice($arguments, 0, count($arguments) - 1))) {
            return $arguments[0];
        }
    }
886131
protected function getKeyFromScriptingCommands(CommandInterface $command)
    {
        if ($command instanceof ScriptCommand) {
            $keys = $command->getKeys();
        } else {
            $keys = array_slice($args = $command->getArguments(), 2, $args[1]);
        }

        if ($keys && $this->checkSameSlotForKeys($keys)) {
            return $keys[0];
        }
    }
1099248
public function getKeyedByPropertyMulti($property)
    {
        $keyed = [];
        foreach ($this as $model) {
            if (empty($keyed[$model->$property])) {
                $keyed[$model->$property] = [];
            }
            $keyed[$model->$property][] = $model;
        }
        return $keyed;
    }
1266900
protected function commandClassToArray(string $commandClass): array
    {
        /** @var CommandInterface $commandClass */
        return [
            $commandClass::getName(),
            $commandClass::getDescription(),
            $commandClass::getHelp(),
            $commandClass::getArguments(),
            $commandClass::getOptions(),
            [$commandClass, CommandInterface::COMMAND_METHOD_NAME],
        ];
    }
233120
protected function getKeyFromScriptingCommands(string $command, array $arguments)
    {
        $keys = \array_slice($arguments, 2, $arguments[1]);

        if ($keys && $this->checkSameSlotForKeys($keys)) {
            return $keys[0];
        }

        return null;
    }
6104
public function commands(array $value = null)
    {
        if (null === $value) {
            return $this->commands;
        }
        $this->commands = [];
        foreach ($value as $name => $command) {
            $this->command($name, $command);
        }
        return $this;
    }
255642
protected function mapInputToCommand($command, array $input)
    {
        $dependencies = [];

        $class = new ReflectionClass($command);

        foreach ($class->getConstructor()->getParameters() as $parameter)
        {
            $name = $parameter->getName();

            if (array_key_exists($name, $input))
            {
                $dependencies[] = $input[$name];
            }
            elseif ($parameter->isDefaultValueAvailable())
            {
                $dependencies[] = $parameter->getDefaultValue();
            }
            else
            {
                throw new InvalidArgumentException("Unable to map input to command: {$name}");
            }
        }

        return $class->newInstanceArgs($dependencies);
    }
1269215
protected function fetchCssProperty($property)
    {
        $name = '(?P<name>[\w\-]*)';
        $args = '(?:\((?P<args>[^\)]+)\))';
        $regexp = '/(?:' . $name . $args . '?)?/is';

        if (preg_match($regexp, $property, $segments)) {
            $result = [];

            $result[ 'name' ] = $segments[ 'name' ];
            $result[ 'args' ] = isset($segments[ 'args' ]) ? explode('|', $segments[ 'args' ]) : [];

            return $result;
        }

        throw new RuntimeException('Invalid selector');
    }
1330302
public function handle(AbstractCommand $command)
    {
        $this->commandDispatcher->handle($command);
        // Now that the command is handled, let's found if there is some events to publish
        $events = $this->extractEventsFromCommand($command);
        foreach ($events as $event) {
            // we will only publish event to synchronous listeners
            $this->publish($event);
        }

        return $command;
    }
577986
protected function executeCommand($command)
    {
        if (method_exists(Process::class, 'fromShellCommandline')) {
            $process = Process::fromShellCommandline($command, null, $this->env);
        } else {
            $process = new Process($command, null, $this->env);
        }

        if (false !== $this->timeout) {
            $process->setTimeout($this->timeout);
        }

        $process->run();

        return [
            $process->getExitCode(),
            $process->getOutput(),
            $process->getErrorOutput(),
        ];
    }
743622
private static function getPropertyValueByParentClasses($source, string $property): array
    {
        $properties = self::getProperties($source, null, true);

        if (empty($properties)) {
            return [
                null,
                false,
            ];
        }

        foreach ($properties as $reflectionProperty) {
            if ($reflectionProperty->getName() === $property) {
                $byReflectionProperty = self::getPropertyValueByReflectionProperty(
                    $source,
                    $property,
                    $reflectionProperty
                );

                return [
                    $byReflectionProperty[0],
                    true,
                ];
            }
        }

        return [
            null,
            false,
        ];
    }
234831
private function getKeyValueProperty($property)
    {
        $result = array();

        // extract key/value pairs
        $valuePairs = explode(',', $property);
        foreach ($valuePairs as $valuePair) {
            // extract key/value of a single value
            $keyValue = explode(':', $valuePair);

            // key and value must be present
            if (!isset($keyValue[1]) || !isset($keyValue[0])) {
                continue;
            }

            $key = trim($keyValue[0]);
            $value = trim($keyValue[1]);

            // key and value must be present
            if (!strlen($key) || !strlen($value)) {
                continue;
            }

            $result[$key] = $value;
        }

        return $result;
    }
370433
public function getProperty($property, $item)
    {
        if (gettype($item) == 'array') {
            return $item[$property];
        } elseif (gettype($item) == 'object') {
            return $item->$property;
        }
        return null;
    }
670357
public function setCommandConfiguration($command, array $properties)
    {
        $url = "selendroid/configure/command/{$command}";
        $properties['command'] = $command;
        $this->driver->curl($this->driver->factoryCommand($url, WebDriver_Command::METHOD_POST, $properties));
        return $this;
    }
298169
protected function getKeyFromZsetAggregationCommands(CommandInterface $command)
    {
        $arguments = $command->getArguments();
        $keys = array_merge(array($arguments[0]), array_slice($arguments, 2, $arguments[1]));

        if ($this->checkSameSlotForKeys($keys)) {
            return $arguments[0];
        }
    }