Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ne-Lexa committed Jun 10, 2019
2 parents d79e0e5 + 302894e commit 993d084
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
.github export-ignore
.gitignore export-ignore
.travis.yml export-ignore
phpunit.xml export-ignore
phpunit.xml.dist export-ignore
tests export-ignore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ composer.lock
/vendor/
/.idea/
*.cache
/phpunit.xml
18 changes: 18 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
filter:
paths: [src/*]
excluded_paths: [vendor/*, tests/*]
before_commands:
- 'composer install --dev --prefer-dist'
tools:
external_code_coverage: true
php_mess_detector: true
php_code_sniffer: true
sensiolabs_security_checker: true
php_code_coverage: true
php_pdepend: true
php_loc:
enabled: true
excluded_dirs: [vendor, tests]
php_cpd:
enabled: true
excluded_dirs: [vendor, tests]
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ install:

script:
- composer validate --no-check-lock
- vendor/bin/phpunit -c phpunit.xml
- vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=coverage.clover --exclude-group proxy

after_success:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
80 changes: 50 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
[![Packagist Version](https://img.shields.io/packagist/v/nelexa/enum.svg)](https://packagist.org/packages/nelexa/enum)
[![Packagist](https://img.shields.io/packagist/dt/nelexa/enum.svg?color=%23ff007f)](https://packagist.org/packages/nelexa/enum)
[![Build Status](https://travis-ci.org/Ne-Lexa/enum.svg?branch=master)](https://travis-ci.org/Ne-Lexa/enum)
[![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)
[![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)
[![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)
[![License](https://img.shields.io/packagist/l/nelexa/enum.svg)](https://packagist.org/packages/nelexa/enum)

Table of Contents
=================
* [nelexa/enum - Enum implementation for PHP](#nelexaenum---enum-implementation-for-php)
* [Table of Contents](#table-of-contents)
* [Installation](#installation)
* [Enum declaration](#enum-declaration)
* [Usage](#usage)
Expand All @@ -17,12 +22,12 @@ Table of Contents
* [Use enum in the type hint](#use-enum-in-the-type-hint)
* [Add some logic to enum](#add-some-logic-to-enum)
* [Initialization of values ​​without constructor](#initialization-of-values-without-constructor)
* [Class Synopsis](#class-synopsis)
* [Usage tips](#usage-tips)
* [Generate PHPDoc for enum class](#generate-phpdoc-for-enum-class)
* [Changelog](#changelog)
* [License](#license)


# Installation
```bash
composer require nelexa/enum
Expand All @@ -35,10 +40,10 @@ composer require nelexa/enum
use Nelexa\Enum;

/**
* @method static self PENDING
* @method static self ACTIVE
* @method static self INACTIVE
* @method static self DELETED
* @method static self PENDING()
* @method static self ACTIVE()
* @method static self INACTIVE()
* @method static self DELETED()
*/
class UserStatus extends Enum
{
Expand Down Expand Up @@ -155,10 +160,10 @@ User status is INACTIVE
<?php

/**
* @method static self PLUS
* @method static self MINUS
* @method static self TIMES
* @method static self DIVIDE
* @method static self PLUS()
* @method static self MINUS()
* @method static self TIMES()
* @method static self DIVIDE()
*/
class Operation extends \Nelexa\Enum
{
Expand Down Expand Up @@ -212,17 +217,17 @@ use Nelexa\Enum;
/**
* Class Planet
*
* @method static self MERCURY
* @method static self VENUS
* @method static self EARTH
* @method static self MARS
* @method static self JUPITER
* @method static self SATURN
* @method static self URANUS
* @method static self NEPTUNE
* @method static self PLUTO
* @method static self MERCURY()
* @method static self VENUS()
* @method static self EARTH()
* @method static self MARS()
* @method static self JUPITER()
* @method static self SATURN()
* @method static self URANUS()
* @method static self NEPTUNE()
* @method static self PLUTO()
*
* @see example https://docs.oracle.com/javase/8/docs/technotes/guides/language/enums.html
* @see https://docs.oracle.com/javase/8/docs/technotes/guides/language/enums.html
*/
class Planet extends Enum
{
Expand Down Expand Up @@ -259,8 +264,7 @@ class Planet extends Enum
*/
protected function initValue($value): void
{
$this->mass = $value[0];
$this->radius = $value[1];
[$this->mass, $this->radius] = $value;
}

public function mass(): float
Expand Down Expand Up @@ -307,6 +311,22 @@ Your weight on NEPTUNE is 199.207413
Your weight on PLUTO is 11.703031
```

## Class Synopsis
```php
abstract class Nelexa\Enum {

/* Methods */
final public static valueOf ( string $name ) : static
final public name ( void ) : string
final public value ( void ) : string | int | float | bool | array | null
final public static values ( void ) : static[]
final public static containsKey ( string $name ) : bool
final public static containsValue ( mixed $value [, bool $strict = true ] ) : bool
final public ordinal ( void ) : int
public __toString ( void ) : string
}
```

# Usage tips
* Even though it is not mandatory to declare enum constants with **UPPERCASE** letters, it is in the best practice to do so.
* Enum classes can have fields and methods along with enum constants.
Expand All @@ -333,15 +353,15 @@ echo \Nelexa\enum_docblock(Planet::MERCURY());
Output:
```
/**
* @method static self MERCURY
* @method static self VENUS
* @method static self EARTH
* @method static self MARS
* @method static self JUPITER
* @method static self SATURN
* @method static self URANUS
* @method static self NEPTUNE
* @method static self PLUTO
* @method static self MERCURY()
* @method static self VENUS()
* @method static self EARTH()
* @method static self MARS()
* @method static self JUPITER()
* @method static self SATURN()
* @method static self URANUS()
* @method static self NEPTUNE()
* @method static self PLUTO()
*/
```

Expand Down
File renamed without changes.

0 comments on commit 993d084

Please sign in to comment.