-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 3d68b72
Showing
14 changed files
with
993 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.php text eol=lf | ||
|
||
# Directories/files not distributed when using Composer option `--prefer-dist` | ||
/.phpstorm.meta.php/ export-ignore | ||
/docs/ export-ignore | ||
/tests/ export-ignore | ||
|
||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/infection.json.dist export-ignore | ||
/mkdocs.yml export-ignore | ||
/phpcs.xml.dist export-ignore | ||
/phpstan.neon.dist export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/phpinsights.php 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Tests | ||
|
||
on: [ push, pull_request ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ ubuntu-latest, windows-latest ] | ||
php: [ 7.1, 7.2, 7.3, 7.4 ] | ||
dependency-version: [ prefer-lowest, prefer-stable ] | ||
|
||
name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.composer/cache/files | ||
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
coverage: none | ||
|
||
- name: Install dependencies | ||
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest | ||
|
||
- name: Execute tests | ||
run: vendor/bin/phpunit |
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,11 @@ | ||
.idea | ||
.php_cs | ||
.php_cs.cache | ||
.phpunit.result.cache | ||
build | ||
composer.lock | ||
coverage | ||
docs | ||
phpunit.xml | ||
psalm.xml | ||
vendor |
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,36 @@ | ||
{ | ||
"name": "cuyz/magic-constant", | ||
"description": "PHP Magic Constants, even more powerful than an Enum", | ||
"keywords": [ | ||
"enum", | ||
"magic constant", | ||
"magic number" | ||
], | ||
"type": "library", | ||
"license": "MIT", | ||
"homepage": "https://github.com/CuyZ/MagicConstant", | ||
"authors": [ | ||
{ | ||
"name": "Nathan Boiron", | ||
"email": "[email protected]", | ||
"homepage": "https://github.com/Mopolo", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.1.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"CuyZ\\MagicConstant\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"CuyZ\\MagicConstant\\Tests\\": "tests" | ||
} | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^7.5" | ||
} | ||
} |
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,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
> | ||
<testsuites> | ||
<testsuite name="Tests suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">src/</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
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,15 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace CuyZ\MagicConstant\Exception; | ||
|
||
use CuyZ\MagicConstant\MagicConstant; | ||
use InvalidArgumentException; | ||
|
||
final class InvalidFormatException extends InvalidArgumentException implements MagicConstantException | ||
{ | ||
public function __construct(MagicConstant $magicConstant, string $format) | ||
{ | ||
parent::__construct(sprintf('The format `%s` does not exist in `%s`', $format, get_class($magicConstant))); | ||
} | ||
} |
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 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace CuyZ\MagicConstant\Exception; | ||
|
||
use InvalidArgumentException; | ||
|
||
final class InvalidKeyException extends InvalidArgumentException implements MagicConstantException | ||
{ | ||
public function __construct(string $className, string $key) | ||
{ | ||
parent::__construct(sprintf('The key `%s` does not exist in `%s`', $key, $className)); | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace CuyZ\MagicConstant\Exception; | ||
|
||
use InvalidArgumentException; | ||
|
||
final class InvalidValueException extends InvalidArgumentException implements MagicConstantException | ||
{ | ||
/** | ||
* @param string $className | ||
* @param mixed $value | ||
*/ | ||
public function __construct(string $className, $value) | ||
{ | ||
if (is_object($value)) { | ||
$value = get_class($value); | ||
} | ||
|
||
parent::__construct(sprintf('The value `%s` does not exist in `%s`', (string)$value, $className)); | ||
} | ||
} |
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,8 @@ | ||
<?php | ||
|
||
namespace CuyZ\MagicConstant\Exception; | ||
|
||
interface MagicConstantException | ||
{ | ||
|
||
} |
Oops, something went wrong.