for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Everlution\NavigationBundle\Bridge\Url;
use Everlution\Navigation\Item\ItemInterface;
use Everlution\Navigation\Url\UrlProviderInterface;
use Everlution\NavigationBundle\Bridge\Item\RoutableInterface;
use Symfony\Component\Routing\RouterInterface;
/**
* Class UrlProvider.
*
* @author Ivan Barlog <[email protected]>
*/
class UrlProvider implements UrlProviderInterface
{
/** @var RouterInterface */
private $router;
public function __construct(RouterInterface $router)
$this->router = $router;
}
* @param ItemInterface $item
* @return string
* @throws ItemIsNotSupportedException
public function getUrl(ItemInterface $item): string
if (false === $item instanceof RoutableInterface) {
throw new ItemIsNotSupportedException($item, RouterInterface::class);
return $this->router->generate($item->getRoute(), $item->getParameters());
public function supports(ItemInterface $item): bool
return $item instanceof RoutableInterface;