Ejemplo n.º 1
0
 /**
  * Constructor.
  * @param  mixed   $content The data which gets encoded to json
  * @param  integer $code    The HTTP status code
  * @param  array   $headers The HTTP headers
  * 
  * @param  \Modulework\Modules\Http\Utilities\HeaderWrapperInterface | null $headerWrapper The wrapper for PHP' s native header releated functions
  * 
  * @return \Modulework\Modules\Http\JsonResponse The new JsonResponse object
  *
  * @throws InvalidArgumentException (from setContent)
  */
 public function __construct($json = null, $code = 200, array $headers = array(), HeaderWrapperInterface $headerWrapper = null)
 {
     parent::__construct('', $code, $headers, $headerWrapper);
     if ($json === null) {
         $json = new stdClass();
     }
     $this->setJson($json);
 }
Ejemplo n.º 2
0
 /**
  * Constructor.
  * @param  string  $content The target URL
  * @param  integer $code    The HTTP status code
  * @param  array   $headers The HTTP headers
  * 
  * @param  \Modulework\Modules\Http\Utilities\HeaderWrapperInterface | null $headerWrapper The wrapper for PHP' s native header releated functions
  * 
  * @return \Modulework\Modules\Http\RedirectResponse The new RedirectResponse object
  *
  * @throws \InvalidArgumentException [(from setContent, setUrl)]
  */
 public function __construct($url = null, $code = 302, array $headers = array(), HeaderWrapperInterface $headerWrapper = null)
 {
     parent::__construct('', $code, $headers, $headerWrapper);
     $this->setUrl($url);
     if (!$this->isRedirect()) {
         throw new InvalidArgumentException('HTTP status code not compatible with a redirect');
     }
 }
Ejemplo n.º 3
0
 /**
  * @dataProvider isInformationalData
  */
 public function testIsInformational($code, $exp)
 {
     $this->assertEquals($exp, Response::make('', $code)->isInformational());
 }