Overview

Namespaces

  • Deimos
    • Request
      • Adapter
  • PHP

Classes

  • Deimos\Request\Request

Interfaces

  • Throwable

Traits

  • Deimos\Request\Adapter\Data
  • Deimos\Request\Adapter\Other
  • Deimos\Request\Adapter\Query
  • Deimos\Request\Adapter\Request
  • Deimos\Request\Adapter\Router
  • Deimos\Request\Adapter\Server
  • Deimos\Request\AdapterExtension
  • Deimos\Request\DefaultAdapter
  • Deimos\Request\RequestExtension

Exceptions

  • BadFunctionCallException
  • Exception
  • InvalidArgumentException
  • LogicException
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
 1: <?php
 2: 
 3: namespace Deimos\Request\Adapter;
 4: 
 5: /**
 6:  * Class Router
 7:  *
 8:  * @package Deimos\Request\Adapter
 9:  *
10:  * @method int attributeInt(string $path = null, mixed $default = 0)
11:  * @method float attributeFloat(string $path = null, mixed $default = 0.0)
12:  * @method bool attributeBool(string $path = null, mixed $default = false)
13:  * @method string attributeEmail(string $path = null, mixed $default = '')
14:  * @method string attributeIP(string $path = null, mixed $default = '')
15:  * @method string attributeURL(string $path = null, mixed $default = '')
16:  * @method mixed attributeUnsafe(string $path = null, mixed $default = '')
17:  */
18: trait Router
19: {
20: 
21:     /**
22:      * @var \Deimos\Router\Router
23:      */
24:     private $router;
25: 
26:     /**
27:      * @var \Deimos\Router\Route
28:      */
29:     private $route;
30: 
31:     /**
32:      * @param \Deimos\Router\Router $router
33:      */
34:     public function setRouter(\Deimos\Router\Router $router)
35:     {
36:         $this->router = $router;
37:     }
38: 
39:     /**
40:      * @param string $path
41:      * @param mixed  $default
42:      *
43:      * @return mixed
44:      *
45:      * @throws \InvalidArgumentException
46:      */
47:     public function attribute($path = null, $default = null)
48:     {
49:         $path = $this->normalizeLow($path);
50: 
51:         return $this->arrGet($this->attributes(), $path, $default);
52:     }
53: 
54:     /**
55:      * @return array
56:      *
57:      * @throws \InvalidArgumentException
58:      */
59:     public function attributes()
60:     {
61:         return $this->route()->attributes();
62:     }
63: 
64:     /**
65:      * @return \Deimos\Router\Route
66:      *
67:      * @throws \InvalidArgumentException
68:      */
69:     private function route()
70:     {
71:         if (!$this->route)
72:         {
73:             $path = $this->urlPath();
74:             $this->router->setMethod($this->method());
75: 
76:             $this->route = $this->router->getCurrentRoute($path);
77:         }
78: 
79:         return $this->route;
80:     }
81: 
82:     /**
83:      * @param string $path
84:      * @param bool   $strip
85:      *
86:      * @return mixed
87:      *
88:      * @throws \Deimos\Helper\Exceptions\ExceptionEmpty
89:      * @throws \InvalidArgumentException
90:      */
91:     public function attributeRequired($path = null, $strip = true)
92:     {
93:         return $this->arrRequired($this->attributes(), $path, $strip);
94:     }
95: 
96: }
API documentation generated by ApiGen