Skip to content

Commit f3c1ea8

Browse files
authored
Merge pull request #4 from dbalabka/enable-travis
Enable travis
2 parents 76444e5 + e9c63ed commit f3c1ea8

30 files changed

+286
-144
lines changed

.travis.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
language: php
2+
3+
matrix:
4+
fast_finish: true
5+
include:
6+
- php: '7.1'
7+
- php: '7.2'
8+
- php: '7.3'
9+
- php: '7.4snapshot'
10+
11+
before_install:
12+
- phpenv config-rm xdebug.ini || echo "No xdebug config."
13+
14+
install:
15+
- composer update --prefer-dist --no-interaction
16+
17+
- mkdir -p coverage/cov coverage/bin
18+
- wget https://phar.phpunit.de/phpcov.phar -O coverage/bin/phpcov
19+
- chmod +x coverage/bin/phpcov
20+
21+
script:
22+
- phpdbg -qrr vendor/bin/phpunit --coverage-php coverage/cov/main.cov
23+
24+
- php examples/card_type.php
25+
- php examples/class_static_construct.php
26+
- php examples/day.php
27+
- php examples/flag.php
28+
- php examples/php-enum_comparision.php
29+
- php examples/planet.php
30+
- php examples/serialization_php74.php
31+
32+
after_script:
33+
- curl -OL https://github.com/php-coveralls/php-coveralls/releases/download/v1.0.0/coveralls.phar
34+
- chmod +x coveralls.phar
35+
- phpdbg -qrr coverage/bin/phpcov merge --clover build/logs/clover.xml coverage/cov
36+
- ./coveralls.phar

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# PHP Enumeration classes
2+
[![Build Status](https://travis-ci.org/dbalabka/php-enumeration.svg?branch=master)](https://travis-ci.org/dbalabka/php-enumeration)
3+
[![Coverage Status](https://coveralls.io/repos/github/dbalabka/php-enumeration/badge.svg)](https://coveralls.io/github/dbalabka/php-enumeration)
4+
25
Implementation of [Enumeration Classes](https://docs.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/enumeration-classes-over-enum-types) in PHP.
36

47
In contrast to [existing solutions](#existing-solutions), this implementation avoids usage of [Magic methods](https://www.php.net/manual/en/language.oop5.magic.php) and
@@ -133,14 +136,16 @@ any static property that isn't an Enum element then you should override the `\Db
133136
$viewAction = Action::$view;
134137

135138
// it is possible to compare Enum elements
136-
var_dump($viewAction === Action::$view);
139+
assert($viewAction === Action::$view);
137140

138141
// you can get Enum element by name
139142
$editAction = Action::valueOf('edit');
143+
assert($editAction === Action::$edit);
140144

141145
// iterate over all Enum elements
142146
foreach (Action::values() as $name => $action) {
143-
echo $action;
147+
assert($action instanceof Action);
148+
assert($name === (string) $action);
144149
}
145150
```
146151

build/php71/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM php:7.1-cli
2+
RUN pecl install xdebug

build/php72/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM php:7.2-cli
2+
RUN pecl install xdebug

build/php73/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM php:7.3-cli
2+
RUN pecl install xdebug
File renamed without changes.

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
"email": "dmitry.balabka@gmail.com"
1010
}
1111
],
12-
"repositories": [{"type": "vcs", "url": "https://github.com/dbalabka/construct-static.git"}],
1312
"require": {
1413
"php": ">=7.1"
1514
},
1615
"require-dev": {
1716
"vladimmi/construct-static": "dev-master",
1817
"myclabs/php-enum": "^1.0",
19-
"phpunit/phpunit": "^8.3",
18+
"phpunit/phpunit": "^7.5",
2019
"phpbench/phpbench": "^0.16.9"
2120
},
2221
"suggest": {

examples/Fixtures/Action.php renamed to examples/Enum/Action.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace Dbalabka\Examples\Fixtures;
4+
namespace Dbalabka\Examples\Enum;
55

66
use Dbalabka\Enumeration;
77

examples/Enum/CardType.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Dbalabka\Examples\Enum;
5+
6+
use Dbalabka\Enumeration;
7+
8+
final class CardType extends Enumeration
9+
{
10+
public static $amex;
11+
public static $visa;
12+
public static $masterCard;
13+
14+
protected static function initializeValues() : void
15+
{
16+
self::$amex = new self();
17+
self::$visa = new self();
18+
self::$masterCard = new self();
19+
}
20+
}
21+
CardType::initialize();

examples/Fixtures/Color.php renamed to examples/Enum/Color.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace Dbalabka\Examples\Fixtures;
4+
namespace Dbalabka\Examples\Enum;
55

66
use Dbalabka\Enumeration;
77

0 commit comments

Comments
 (0)