Skip to content

Commit 993d084

Browse files
committed
Merge branch 'release/1.0.1'
2 parents d79e0e5 + 302894e commit 993d084

14 files changed

+189
-119
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
.github export-ignore
33
.gitignore export-ignore
44
.travis.yml export-ignore
5-
phpunit.xml export-ignore
5+
phpunit.xml.dist export-ignore
66
tests export-ignore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ composer.lock
22
/vendor/
33
/.idea/
44
*.cache
5+
/phpunit.xml

.scrutinizer.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
filter:
2+
paths: [src/*]
3+
excluded_paths: [vendor/*, tests/*]
4+
before_commands:
5+
- 'composer install --dev --prefer-dist'
6+
tools:
7+
external_code_coverage: true
8+
php_mess_detector: true
9+
php_code_sniffer: true
10+
sensiolabs_security_checker: true
11+
php_code_coverage: true
12+
php_pdepend: true
13+
php_loc:
14+
enabled: true
15+
excluded_dirs: [vendor, tests]
16+
php_cpd:
17+
enabled: true
18+
excluded_dirs: [vendor, tests]

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ install:
1515

1616
script:
1717
- composer validate --no-check-lock
18-
- vendor/bin/phpunit -c phpunit.xml
18+
- vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=coverage.clover --exclude-group proxy
19+
20+
after_success:
21+
- wget https://scrutinizer-ci.com/ocular.phar
22+
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover

README.md

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
[![Packagist Version](https://img.shields.io/packagist/v/nelexa/enum.svg)](https://packagist.org/packages/nelexa/enum)
44
[![Packagist](https://img.shields.io/packagist/dt/nelexa/enum.svg?color=%23ff007f)](https://packagist.org/packages/nelexa/enum)
55
[![Build Status](https://travis-ci.org/Ne-Lexa/enum.svg?branch=master)](https://travis-ci.org/Ne-Lexa/enum)
6+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Ne-Lexa/enum/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Ne-Lexa/enum/?branch=master)
7+
[![Code Coverage](https://scrutinizer-ci.com/g/Ne-Lexa/enum/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Ne-Lexa/enum/?branch=master)
8+
[![Build Status](https://scrutinizer-ci.com/g/Ne-Lexa/enum/badges/build.png?b=master)](https://scrutinizer-ci.com/g/Ne-Lexa/enum/build-status/master)
69
[![License](https://img.shields.io/packagist/l/nelexa/enum.svg)](https://packagist.org/packages/nelexa/enum)
710

811
Table of Contents
912
=================
13+
* [nelexa/enum - Enum implementation for PHP](#nelexaenum---enum-implementation-for-php)
14+
* [Table of Contents](#table-of-contents)
1015
* [Installation](#installation)
1116
* [Enum declaration](#enum-declaration)
1217
* [Usage](#usage)
@@ -17,12 +22,12 @@ Table of Contents
1722
* [Use enum in the type hint](#use-enum-in-the-type-hint)
1823
* [Add some logic to enum](#add-some-logic-to-enum)
1924
* [Initialization of values ​​without constructor](#initialization-of-values-without-constructor)
25+
* [Class Synopsis](#class-synopsis)
2026
* [Usage tips](#usage-tips)
2127
* [Generate PHPDoc for enum class](#generate-phpdoc-for-enum-class)
2228
* [Changelog](#changelog)
2329
* [License](#license)
2430

25-
2631
# Installation
2732
```bash
2833
composer require nelexa/enum
@@ -35,10 +40,10 @@ composer require nelexa/enum
3540
use Nelexa\Enum;
3641

3742
/**
38-
* @method static self PENDING
39-
* @method static self ACTIVE
40-
* @method static self INACTIVE
41-
* @method static self DELETED
43+
* @method static self PENDING()
44+
* @method static self ACTIVE()
45+
* @method static self INACTIVE()
46+
* @method static self DELETED()
4247
*/
4348
class UserStatus extends Enum
4449
{
@@ -155,10 +160,10 @@ User status is INACTIVE
155160
<?php
156161

157162
/**
158-
* @method static self PLUS
159-
* @method static self MINUS
160-
* @method static self TIMES
161-
* @method static self DIVIDE
163+
* @method static self PLUS()
164+
* @method static self MINUS()
165+
* @method static self TIMES()
166+
* @method static self DIVIDE()
162167
*/
163168
class Operation extends \Nelexa\Enum
164169
{
@@ -212,17 +217,17 @@ use Nelexa\Enum;
212217
/**
213218
* Class Planet
214219
*
215-
* @method static self MERCURY
216-
* @method static self VENUS
217-
* @method static self EARTH
218-
* @method static self MARS
219-
* @method static self JUPITER
220-
* @method static self SATURN
221-
* @method static self URANUS
222-
* @method static self NEPTUNE
223-
* @method static self PLUTO
220+
* @method static self MERCURY()
221+
* @method static self VENUS()
222+
* @method static self EARTH()
223+
* @method static self MARS()
224+
* @method static self JUPITER()
225+
* @method static self SATURN()
226+
* @method static self URANUS()
227+
* @method static self NEPTUNE()
228+
* @method static self PLUTO()
224229
*
225-
* @see example https://docs.oracle.com/javase/8/docs/technotes/guides/language/enums.html
230+
* @see https://docs.oracle.com/javase/8/docs/technotes/guides/language/enums.html
226231
*/
227232
class Planet extends Enum
228233
{
@@ -259,8 +264,7 @@ class Planet extends Enum
259264
*/
260265
protected function initValue($value): void
261266
{
262-
$this->mass = $value[0];
263-
$this->radius = $value[1];
267+
[$this->mass, $this->radius] = $value;
264268
}
265269

266270
public function mass(): float
@@ -307,6 +311,22 @@ Your weight on NEPTUNE is 199.207413
307311
Your weight on PLUTO is 11.703031
308312
```
309313

314+
## Class Synopsis
315+
```php
316+
abstract class Nelexa\Enum {
317+
318+
/* Methods */
319+
final public static valueOf ( string $name ) : static
320+
final public name ( void ) : string
321+
final public value ( void ) : string | int | float | bool | array | null
322+
final public static values ( void ) : static[]
323+
final public static containsKey ( string $name ) : bool
324+
final public static containsValue ( mixed $value [, bool $strict = true ] ) : bool
325+
final public ordinal ( void ) : int
326+
public __toString ( void ) : string
327+
}
328+
```
329+
310330
# Usage tips
311331
* Even though it is not mandatory to declare enum constants with **UPPERCASE** letters, it is in the best practice to do so.
312332
* Enum classes can have fields and methods along with enum constants.
@@ -333,15 +353,15 @@ echo \Nelexa\enum_docblock(Planet::MERCURY());
333353
Output:
334354
```
335355
/**
336-
* @method static self MERCURY
337-
* @method static self VENUS
338-
* @method static self EARTH
339-
* @method static self MARS
340-
* @method static self JUPITER
341-
* @method static self SATURN
342-
* @method static self URANUS
343-
* @method static self NEPTUNE
344-
* @method static self PLUTO
356+
* @method static self MERCURY()
357+
* @method static self VENUS()
358+
* @method static self EARTH()
359+
* @method static self MARS()
360+
* @method static self JUPITER()
361+
* @method static self SATURN()
362+
* @method static self URANUS()
363+
* @method static self NEPTUNE()
364+
* @method static self PLUTO()
345365
*/
346366
```
347367

File renamed without changes.

0 commit comments

Comments
 (0)