View sourcecode

The following files exists in this folder. Click to view.

CResponseBasic.php

1 lines ASCII Unix (LF)
1
<?php

namespace Anax\Response;

/**
 * Handling a response.
 *
 */
class CResponseBasic
{


    /**
    * Properties
    *
    */
    private $headers; // Set all headers to send



    /**
     * Set headers.
     *
     * @param string $header type of header to set
     *
     * @return $this
     */
    public function setHeader($header)
    {
        $this->header[] = $header;
    }



    /**
     * Send headers.
     *
     * @return $this
     */
    public function sendHeaders()
    {
        if (empty($this->headers)) {
            return;
        }

        foreach ($this->headers as $header) {
            switch ($this->header) {
                case '403':
                    header('HTTP/1.0 403 Forbidden');
                    break;

                case '404':
                    header('HTTP/1.0 404 Not Found');
                    break;

                default:
                    throw new \Exception("Unkown header type.");
            }
        }

        return $this;
    }
}