Esempio n. 1
0
 /**
  * @param HttpRequestInterface $request
  *
  * @return bool
  */
 public function matches(HttpRequestInterface $request)
 {
     if ($this->method != $request->getMethod()) {
         return false;
     }
     $requestPathSegments = explode('/', $request->getPath());
     $routePathSegments = explode('/', $this->path);
     if (count($requestPathSegments) != count($routePathSegments)) {
         return false;
     }
     $pathParameters = [];
     foreach ($routePathSegments as $index => $pathSegment) {
         if (preg_match('/\\{(.*)\\}/', $pathSegment, $matches)) {
             $pathParameters[$matches[1]] = $requestPathSegments[$index];
             continue;
         }
         if ($pathSegment != $requestPathSegments[$index]) {
             return false;
         }
     }
     foreach ($pathParameters as $name => $value) {
         $request->addPathParameter($name, $value);
     }
     return true;
 }
 /**
  * @param HttpRequestInterface $request
  *
  * @return Member
  */
 private function mapInputToMember(HttpRequestInterface $request)
 {
     return new Member(new Uuid(), $request->getParameter('name'), $request->getParameter('email'));
 }
 /**
  * @param HttpRequestInterface $request
  *
  * @return Meetup
  */
 private function mapInputToMeetup(HttpRequestInterface $request)
 {
     return new Meetup(new Uuid(), $request->getParameter('title'), new \DateTime($request->getParameter('date')), (int) $request->getParameter('capacity'));
 }
 /**
  * @param HttpRequestInterface $request
  *
  * @return Rsvp
  */
 private function mapInputToRsvp(HttpRequestInterface $request)
 {
     return new Rsvp($this->memberReader->getMember(new Uuid($request->getParameter('member'))), $this->meetupReader->getMeetup(new Uuid($request->getParameter('meetup'))), $request->getParameter('rsvp'));
 }