2017 © Pedro Peláez
 

library enum-generator

emun class code generator

image

4slv/enum-generator

emun class code generator

  • Friday, June 15, 2018
  • by 4slv
  • Repository
  • 0 Watchers
  • 0 Stars
  • 360 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 3 Versions
  • 543 % Grown

The README.md

enum-generator

Генератор кода класса перечисляемого типа Enum myclabs/php-enum, (*1)

Как использовать

Пример:, (*2)

use EnumGenerator\EnumElement;
use EnumGenerator\EnumGenerator;

require_once 'vendor/autoload.php';

$projectPath = '/tmp/enum-generator';
$enumClassName = 'Sex';
$enumNamespace = 'Enum';
$enumClassComment = 'Пол';
$enumCodeDirRelativePath = 'enum';
$enumElementList = [
    (new EnumElement())->setName('MALE')->setValue('Male')->setComment('Мужчина'),
    (new EnumElement())->setName('FEMALE')->setValue('Female')->setComment('Женщина')
];

$enumGenerator = new EnumGenerator();
$enumGenerator
    ->setProjectPath($projectPath) // $projectPath абсолютный путь к папке проекта
    ->setClassName($enumClassName) // $enumClassName название класса с перечислениями
    ->setEnumNamespace($enumNamespace) // $enumNamespace пространство имен класса с перечислениями
    ->setClassComment($enumClassComment) // $enumClassComment комментарий к классу с перечислениями
    ->setEnumCodeRelativePath($enumCodeDirRelativePath) // $enumCodeDirRelativePath относительный путь к папке
    ->setEnumElementList($enumElementList) // $enumElementList список описания элементов перечисления
    ->generate(); // генерация класса

В результате сгенерируется файл: /tmp/enum-generator/Sex.php, (*3)

со следующим содержимым:, (*4)

<?php
namespace Enum;

use MyCLabs\Enum\Enum;

/** Пол */
class Sex extends Enum
{
    /** Мужчина */
    const MALE = 'Male';

    /** Женщина */
    const FEMALE = 'Female';


}

The Versions

15/06 2018

dev-master

9999999-dev

emun class code generator

  Sources   Download

MIT

The Requires

 

by Alexey Dobrynin

15/06 2018

v1.0.1

1.0.1.0

emun class code generator

  Sources   Download

MIT

The Requires

 

by Alexey Dobrynin

07/05 2018

v1.0.0

1.0.0.0

emun class code generator

  Sources   Download

MIT

The Requires

 

by Alexey Dobrynin