예제 #1
0
파일: Router.php 프로젝트: elan4u/bank
 public function route(Request $request)
 {
     $parts = explode('/', $request->getURI());
     unset($parts[0]);
     $controller = array_shift($parts);
     if (!isset($this->values[$controller])) {
         if ($this->defaultController === NULL) {
             throw new Exception();
         }
         return $this->defaultController;
     }
     if (count($parts) % 2 != 0) {
         throw new Exception();
     }
     $keys = array_keys($parts);
     $count = count($keys);
     for ($i = 0; $i < $count; $i += 2) {
         $request->set($parts[$keys[$i]], $parts[$keys[$i + 1]]);
     }
     return $this->values[$controller];
 }
예제 #2
0
파일: RequestTest.php 프로젝트: elan4u/bank
 /**
  * @covers bankaccount\framework\http\Request::__construct
  * @covers bankaccount\framework\http\Request::getURI
  */
 public function testRequestUriCanBeRetrieved()
 {
     $request = new Request('/');
     $this->assertEquals('/', $request->getURI());
 }