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
811Table 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
2833composer require nelexa/enum
@@ -35,10 +40,10 @@ composer require nelexa/enum
3540use 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 */
4348class 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 */
163168class 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 */
227232class 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
307311Your 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());
333353Output:
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
0 commit comments