Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change collection type for Route Collections #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/Routes/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@
namespace Lord\Laroute\Routes;

use Illuminate\Routing\Route;
use Illuminate\Routing\RouteCollection;
use Illuminate\Routing\AbstractRouteCollection;
use Illuminate\Support\Arr;
use Lord\Laroute\Routes\Exceptions\ZeroRoutesException;

class Collection extends \Illuminate\Support\Collection
{
public function __construct(RouteCollection $routes, $filter, $namespace)
public function __construct(AbstractRouteCollection $routes, $filter, $namespace)
{
$this->items = $this->parseRoutes($routes, $filter, $namespace);
}

/**
* Parse the routes into a jsonable output.
*
* @param RouteCollection $routes
* @param AbstractRouteCollection $routes
* @param string $filter
* @param string $namespace
*
* @return array
* @throws ZeroRoutesException
*/
protected function parseRoutes(RouteCollection $routes, $filter, $namespace)
protected function parseRoutes(AbstractRouteCollection $routes, $filter, $namespace)
{
$this->guardAgainstZeroRoutes($routes);

$results = [];

foreach ($routes as $route) {
foreach ($routes->getRoutes() as $route) {
$results[] = $this->getRouteInformation($route, $filter, $namespace);
}

Expand All @@ -40,11 +40,11 @@ protected function parseRoutes(RouteCollection $routes, $filter, $namespace)
/**
* Throw an exception if there aren't any routes to process
*
* @param RouteCollection $routes
* @param AbstractRouteCollection $routes
*
* @throws ZeroRoutesException
*/
protected function guardAgainstZeroRoutes(RouteCollection $routes)
protected function guardAgainstZeroRoutes(AbstractRouteCollection $routes)
{
if (count($routes) < 1) {
throw new ZeroRoutesException("You don't have any routes!");
Expand Down