-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
176 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
|
||
/confidential/* | ||
!/confidential/.htaccess | ||
!/confidential/.meta | ||
|
||
/data/cache/* | ||
!/data/cache/.gitkeep | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
VERSION=3.16.2 | ||
BUILD=dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
namespace App\Support; | ||
|
||
class Meta | ||
{ | ||
private MetaParser $metaParser; | ||
private Path $path; | ||
private array $meta; | ||
|
||
public function __construct(MetaParser $metaParser, Path $path) | ||
{ | ||
$this->metaParser = $metaParser; | ||
$this->path = $path; | ||
} | ||
|
||
public function load() | ||
{ | ||
$path = $this->path->to("confidential/.meta"); | ||
$this->meta = $this->metaParser->parse($path); | ||
} | ||
|
||
public function getVersion(): string | ||
{ | ||
return $this->get("VERSION", "unknown"); | ||
} | ||
|
||
public function getBuild(): string | ||
{ | ||
return $this->get("BUILD", "unknown"); | ||
} | ||
|
||
/** | ||
* @param string $key | ||
* @param string|null $default | ||
* @return mixed|null | ||
*/ | ||
public function get($key, $default = null) | ||
{ | ||
return array_get($this->meta, $key, $default); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
namespace App\Support; | ||
|
||
class MetaParser | ||
{ | ||
private FileSystemContract $fileSystem; | ||
|
||
public function __construct(FileSystemContract $fileSystem) | ||
{ | ||
$this->fileSystem = $fileSystem; | ||
} | ||
|
||
/** | ||
* @param string $path | ||
* @return array | ||
*/ | ||
public function parse($path): array | ||
{ | ||
$lines = explode(PHP_EOL, $this->fileSystem->get($path)); | ||
|
||
return collect($lines) | ||
->flatMap(function ($line) { | ||
$exploded = explode("=", $line); | ||
|
||
if (count($exploded) != 2) { | ||
return []; | ||
} | ||
|
||
return [trim($exploded[0]) => trim($exploded[1])]; | ||
}) | ||
->all(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.