commandName = $commandName; $this->targetName = $targetName; $this->type = $type; $this->completion = $completion; } /** * Return the stored completion, or the results returned from the completion callback * * @return array */ public function run() { if ($this->isCallable()) { return call_user_func($this->completion); } return $this->completion; } /** * Get type of input (option/argument) the completion should be run for * * @see CompletionInterface::ALL_TYPES * @return string|null */ public function getType() { return $this->type; } /** * Set type of input (option/argument) the completion should be run for * * @see CompletionInterface::ALL_TYPES * @param string|null $type */ public function setType($type) { $this->type = $type; } /** * Get the command name the completion should be run for * * @see CompletionInterface::ALL_COMMANDS * @return string|null */ public function getCommandName() { return $this->commandName; } /** * Set the command name the completion should be run for * * @see CompletionInterface::ALL_COMMANDS * @param string|null $commandName */ public function setCommandName($commandName) { $this->commandName = $commandName; } /** * Set the option/argument name the completion should be run for * * @see setType() * @return string */ public function getTargetName() { return $this->targetName; } /** * Get the option/argument name the completion should be run for * * @see getType() * @param string $targetName */ public function setTargetName($targetName) { $this->targetName = $targetName; } /** * Return the array or callback configured for for the Completion * * @return array|callable */ public function getCompletion() { return $this->completion; } /** * Set the array or callback to return/run when Completion is run * * @see run() * @param array|callable $completion */ public function setCompletion($completion) { $this->completion = $completion; } /** * Check if the configured completion value is a callback function * * @return bool */ public function isCallable() { return is_callable($this->completion); } }