PhpGitHooks\Module\Configuration\Service\PrePushConfigurator::configure PHP Метод

configure() публичный статический Метод

public static configure ( Composer\IO\IOInterface $input, PrePush $prePush )
$input Composer\IO\IOInterface
$prePush PhpGitHooks\Module\Configuration\Domain\PrePush
    public static function configure(IOInterface $input, PrePush $prePush)
    {
        $answer = $input->ask(HookQuestions::PRE_PUSH_HOOK_QUESTION, HookQuestions::DEFAULT_TOOL_ANSWER);
        $prePush = $prePush->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));
        if (true === $prePush->isEnabled()) {
            $rightMessageAnswer = $input->ask(HookQuestions::PRE_PUSH_RIGHT_MESSAGE, HookQuestions::PRE_PUSH_RIGHT_MESSAGE_DEFAULT);
            $errorMessageAnswer = $input->ask(HookQuestions::PRE_PUSH_ERROR_MESSAGE, HookQuestions::PRE_PUSH_ERROR_MESSAGE_DEFAULT);
            $prePush = $prePush->setMessages(new Messages(new Message($rightMessageAnswer), new Message($errorMessageAnswer)));
        }
        return $prePush;
    }

Usage Example

Пример #1
0
 /**
  * @param PrePush     $prePushData
  * @param IOInterface $input
  *
  * @return PrePush
  */
 public function process(PrePush $prePushData, IOInterface $input)
 {
     $this->input = $input;
     if (true === $prePushData->isUndefined()) {
         $prePushData = PrePushConfigurator::configure($this->input, $prePushData);
     }
     if (true === $prePushData->isEnabled()) {
         $prePushData = $prePushData->setExecute($this->configTools($prePushData->getExecute()));
     }
     return $prePushData;
 }
PrePushConfigurator