Skip to content

Commit

Permalink
fix: Manage exposer
Browse files Browse the repository at this point in the history
  • Loading branch information
taorepoara committed Nov 29, 2023
1 parent b6d6886 commit f964cb0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 19 deletions.
32 changes: 13 additions & 19 deletions src/Manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,26 @@
namespace Lenra\App;

use Lenra\App\Components\Route;
use Lenra\App\Manifest\Exposer;

class Manifest implements \JsonSerializable {
protected string $version;
/**
* @var Route[]
*/
protected array $routes;
protected Exposer $json;
protected Exposer $lenra;

/**
* @param string
* @param Route[]
*/
public function __construct(
string $version,
array $routes
) {
$this->version = $version;
$this->routes = $routes;
public function json(Exposer $exposer): Manifest {
$this->json = $exposer;
return $this;
}

public function lenra(Exposer $exposer): Manifest {
$this->lenra = $exposer;
return $this;
}

public function jsonSerialize() {
return [
'version' => $this->version,
'routes' => array_map(function ($route) {
return $route->jsonSerialize();
}, $this->routes),
'json' => $this->json->jsonSerialize(),
'lenra' => $this->lenra->jsonSerialize(),
];
}
}
34 changes: 34 additions & 0 deletions src/Manifest/Exposer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Lenra\App\Manifest;

use Lenra\App\Components\View;

class Exposer implements \JsonSerializable {
protected string $version;
/**
* @var Route[]
*/
protected array $routes;

/**
* @param string
* @param Route[]
*/
public function __construct(
string $version,
array $routes
) {
$this->version = $version;
$this->routes = $routes;
}

public function jsonSerialize() {
return [
'version' => $this->version,
'routes' => array_map(function ($route) {
return $route->jsonSerialize();
}, $this->routes),
];
}
}

0 comments on commit f964cb0

Please sign in to comment.