Пример #1
0
 public function setStatus($status)
 {
     if (!is_int($status)) {
         $status = StatusCodes::getCode($status);
     }
     $this->status = $status;
     return $this;
 }
Пример #2
0
 public function matches($other)
 {
     $responseStatus = $this->controller->response()->status();
     if (null === $responseStatus) {
         $responseStatus = 200;
     } elseif (!is_int($responseStatus)) {
         $responseStatus = StatusCodes::getCode($responseStatus);
     }
     if (is_string($other)) {
         if (in_array($other, self::$RANGED_STATUS_TYPES)) {
             return $this->matchRangedStatus($other, $responseStatus);
         } else {
             $otherCode = StatusCodes::getCode($other);
             return $otherCode == $responseStatus;
         }
     } elseif (is_int($other)) {
         return $other == $responseStatus;
     } else {
         throw new \InvalidArgumentException(sprintf("First argument must be either string or int, %s passed", gettype($other)));
     }
 }