-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from coenjacobs/config-value-object
Config value object instead of manually reading the file
- Loading branch information
Showing
36 changed files
with
1,077 additions
and
512 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
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
version: '3.4' | ||
services: | ||
builder: | ||
build: | ||
|
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 @@ | ||
error_reporting=E_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
zend_extension=xdebug | ||
|
||
[xdebug] | ||
xdebug.mode=develop,debug | ||
xdebug.client_host=host.docker.internal | ||
xdebug.start_with_request=yes |
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,67 @@ | ||
<?php | ||
|
||
namespace CoenJacobs\Mozart\Config; | ||
|
||
use CoenJacobs\Mozart\Composer\Autoload\Autoloader; | ||
use stdClass; | ||
|
||
class Autoload | ||
{ | ||
/** @var array<Autoloader> */ | ||
public array $autoloaders = []; | ||
|
||
public function setupAutoloaders(stdClass $autoloadData): void | ||
{ | ||
$autoloaders = []; | ||
|
||
if (isset($autoloadData->{'psr-4'})) { | ||
$psr4Autoloaders = (array) $autoloadData->{'psr-4'}; | ||
foreach ($psr4Autoloaders as $key => $value) { | ||
$autoloader = new Psr4(); | ||
$autoloader->namespace = $key; | ||
$autoloader->processConfig($value); | ||
$autoloaders[] = $autoloader; | ||
} | ||
} | ||
|
||
if (isset($autoloadData->{'psr-0'})) { | ||
$psr0Autoloaders = (array) $autoloadData->{'psr-0'}; | ||
foreach ($psr0Autoloaders as $key => $value) { | ||
$autoloader = new Psr0(); | ||
$autoloader->namespace = $key; | ||
$autoloader->processConfig($value); | ||
$autoloaders[] = $autoloader; | ||
} | ||
} | ||
|
||
if (isset($autoloadData->classmap)) { | ||
$autoloader = new Classmap(); | ||
$autoloader->processConfig($autoloadData->classmap); | ||
$autoloaders[] = $autoloader; | ||
} | ||
|
||
$this->setAutoloaders($autoloaders); | ||
} | ||
|
||
/** | ||
* @param array<Autoloader> $autoloaders | ||
*/ | ||
public function setAutoloaders(array $autoloaders): void | ||
{ | ||
foreach ($autoloaders as $autoloader) { | ||
if (! $autoloader instanceof Autoloader) { | ||
continue; | ||
} | ||
|
||
array_push($this->autoloaders, $autoloader); | ||
} | ||
} | ||
|
||
/** | ||
* @return Autoloader[] | ||
*/ | ||
public function getAutoloaders(): array | ||
{ | ||
return $this->autoloaders; | ||
} | ||
} |
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,37 @@ | ||
<?php | ||
|
||
namespace CoenJacobs\Mozart\Config; | ||
|
||
use CoenJacobs\Mozart\Composer\Autoload\Autoloader; | ||
use Exception; | ||
|
||
class Classmap implements Autoloader | ||
{ | ||
/** @var string[] */ | ||
public $files = []; | ||
|
||
/** @var string[] */ | ||
public $paths = []; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function processConfig($autoloadConfig): void | ||
{ | ||
foreach ($autoloadConfig as $value) { | ||
if ('.php' == substr($value, -4, 4)) { | ||
array_push($this->files, $value); | ||
} else { | ||
array_push($this->paths, $value); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
public function getSearchNamespace(): string | ||
{ | ||
throw new Exception('Classmap autoloaders do not contain a namespace and this method can not be used.'); | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
namespace CoenJacobs\Mozart\Config; | ||
|
||
class Extra | ||
{ | ||
public ?Mozart $mozart = null; | ||
|
||
public function getMozart(): ?Mozart | ||
{ | ||
return $this->mozart; | ||
} | ||
} |
Oops, something went wrong.