Exemple #1
0
 /**
  * Add action to someone
  *
  * @param array $commandArgs
  *
  * @return string
  * @throws \Exception
  */
 public function add(array $commandArgs)
 {
     if (count($commandArgs) < 4 || !$this->isAuthorizedActionType($commandArgs[2])) {
         $message = 'Three params are mandatory and second param must be in ' . implode(', ', self::authorizedActionType);
         return $this->help(['help', 'add', $message]);
     }
     if (!is_numeric($commandArgs[3]) || $commandArgs[3] <= 0) {
         return $this->help(['help', 'add', 'Third argument must be positive number']);
     }
     $userSlackName = $commandArgs[1];
     $number = $commandArgs[3];
     $actionType = $commandArgs[2];
     $params = [':id' => $this->actionModel->getNextId(), ':date' => date('Y/m/d'), ':nb_minute' => $number, ':user_id' => $this->userModel->getUserId($userSlackName), ':action_type' => $actionType, ':sprint_number' => getenv('SPRINT_NUMBER')];
     $this->actionModel->insert($params);
     $text = "*Add {$actionType}* :\n";
     $text .= sprintf('%d %s has been added to %s', $number, $actionType, $userSlackName);
     return $text;
 }