Skip to content

Commit

Permalink
Simplify the helpers further
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Apr 25, 2024
1 parent 43ac245 commit 9b2c62d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function handle(): int
{
$routes = new RouteList();

$this->table($routes->headers(), $routes->body());
$this->table($routes->header(), $routes->rows());

return Command::SUCCESS;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/framework/src/Support/Internal/RouteList.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public function __construct()
$this->routes = $this->generate();
}

public function body(): array
public function rows(): array
{
return $this->routes;
}

public function headers(): array
public function header(): array
{
return array_map(function (string $key): string {
return ucwords(str_replace('_', ' ', $key));
Expand All @@ -40,7 +40,7 @@ public function headers(): array
protected function generate(): array
{
return array_map(function (Route $route): array {
return (new RouteListItem($route))->toArray();
return (new RouteListItem($route))->getColumns();
}, array_values(Hyde::routes()->all()));
}
}
5 changes: 2 additions & 3 deletions packages/framework/src/Support/Internal/RouteListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Hyde\Pages\InMemoryPage;
use Hyde\Support\Models\Route;
use Hyde\Console\Concerns\Command;
use Illuminate\Contracts\Support\Arrayable;

use function sprintf;
use function file_exists;
Expand All @@ -18,7 +17,7 @@
/**
* @internal This class is internal and should not be depended on outside the HydePHP framework code.
*/
class RouteListItem implements Arrayable
class RouteListItem
{
protected Route $route;

Expand All @@ -27,7 +26,7 @@ public function __construct(Route $route)
$this->route = $route;
}

public function toArray(): array
public function getColumns(): array
{
return [
'page_type' => $this->stylePageType($this->route->getPageClass()),
Expand Down

0 comments on commit 9b2c62d

Please sign in to comment.