-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial configuration feature implementation. Closes #86.
- Loading branch information
1 parent
a249c96
commit 33eb086
Showing
15 changed files
with
415 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
* text=auto | ||
|
||
/example export-ignore | ||
/tests export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
|
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,14 @@ | ||
namespace: Vendor\Project | ||
test-framework: phpspec | ||
license: MIT | ||
php: 5.6 | ||
|
||
construct-with: | ||
- git | ||
- phpcs | ||
- vagrant | ||
- editor-config | ||
- env | ||
- lgtm | ||
- github-templates | ||
- code-of-conduct |
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,54 @@ | ||
<?php | ||
|
||
namespace JonathanTorres\Construct; | ||
|
||
use Symfony\Component\Yaml\Yaml; | ||
|
||
class Configuration | ||
{ | ||
/** | ||
* Get settings derived from the configuration file. | ||
* | ||
* @param string $configurationFile Path to the configuration file. | ||
* @param string $projectName Name of the project. | ||
* @param string $keywords Composer keywords. | ||
* @param \JonathanTorres\Construct\Helpers\Filesystem $filesystemHelper | ||
* | ||
* @return \JonathanTorres\Construct\Settings | ||
*/ | ||
public static function getSettings($configurationFile, $projectName, $keywords, $filesystemHelper) | ||
{ | ||
if (!$filesystemHelper->isFile($configurationFile)) { | ||
$exceptionMessage = "Configuration file '$configurationFile' is not existent."; | ||
throw new \RuntimeException($exceptionMessage); | ||
} | ||
|
||
if (!$filesystemHelper->isReadable($configurationFile)) { | ||
$exceptionMessage = "Configuration file '$configurationFile' is not readable."; | ||
throw new \RuntimeException($exceptionMessage); | ||
} | ||
|
||
$configuration = Yaml::parse($filesystemHelper->get($configurationFile)); | ||
|
||
if (isset($configuration['construct-with'])) { | ||
$configuration['construct-with'] = array_flip($configuration['construct-with']); | ||
} | ||
|
||
return new Settings( | ||
$projectName, | ||
isset($configuration['test-framework']) ? $configuration['test-framework'] : (new Defaults())->testingFrameworks[0], | ||
isset($configuration['license']) ? $configuration['license'] : (new Defaults())->licenses[0], | ||
isset($configuration['namespace']) ? $configuration['namespace'] : null, | ||
isset($configuration['construct-with']['git']) ? true : false, | ||
isset($configuration['construct-with']['phpcs']) ? true : false, | ||
$keywords, | ||
isset($configuration['construct-with']['vagrant']) ? true : false, | ||
isset($configuration['construct-with']['editor-config']) ? true : false, | ||
isset($configuration['php']) ? (string) $configuration['php'] : PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, | ||
isset($configuration['construct-with']['env']) ? true : false, | ||
isset($configuration['construct-with']['lgtm']) ? true : false, | ||
isset($configuration['construct-with']['github-templates']) ? true : false, | ||
isset($configuration['construct-with']['code-of-conduct']) ? true : false | ||
); | ||
} | ||
} |
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.