コード例 #1
0
 /**
  * Transforms an object (route) to a string (id).
  *
  * @param RouteInterface|string $route
  *
  * @return string
  *
  * @throws TransformationFailedException if object (route) is of wrong type
  */
 public function transform($route)
 {
     if (null === $route) {
         return;
     }
     if ($route instanceof RouteInterface || $route instanceof Generic) {
         return $route->getId();
     }
     throw new TransformationFailedException(sprintf('"%s" should be of type %s or %s!', get_class($route), RouteInterface::class, Generic::class));
 }
コード例 #2
0
 /**
  * Transforms an object (route) to a string (id).
  *
  * @param RouteInterface|string $route
  *
  * @return string
  *
  * @throws TransformationFailedException if object (route) is of wrong type
  */
 public function transform($route)
 {
     if (null === $route) {
         return;
     }
     if (!$route instanceof RouteInterface) {
         throw new UnexpectedTypeException($route, RouteInterface::class);
     }
     return $route->getId();
 }
コード例 #3
0
 public function it_should_transform_route_to_id(RouteInterface $route)
 {
     $route->getId()->willReturn('/some/path/id');
     $this->transform($route)->shouldReturn('/some/path/id');
 }