2017 © Pedro Peláez
 

library rapture-generator

Rapture PHP generator component

image

iuliann/rapture-generator

Rapture PHP generator component

  • Thursday, June 15, 2017
  • by iuliann
  • Repository
  • 1 Watchers
  • 0 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 50 % Grown

The README.md

Rapture PHP code Generator

PhpVersion License, (*1)

PHP code generator., (*2)

Requirements

  • PHP v7.0
  • php-pcre

Install

composer require mrjulio/rapture-generator

Quick start

$class = new PhpClass('Test');
$class->setNamespace('Demo')
    ->setIsAbstract(true)
    ->setIsFinal(true)
    ->setExtends('\Rapture\Component\Definition\ClassAbstract')
    ->addImplements('\Rapture\Component\Definition\ClassInterface')
    ->addTrait('\Rapture\Component\Definition\ClassTrait')
    ->addConstant('status_on', 1)
    ->addConstant('status_off', 2)
    ->addProperty(new PhpProperty('status', 'self::STATUS_OFF', PhpMethod::KEYWORD_PROTECTED))
    ->addMethod(
        new PhpMethod(
            'setStatus',
            '$this->status = $status;' . "\n" . "\n" . 'return $this;',
            PhpMethod::KEYWORD_PUBLIC,
            [['status', 'int', 'self::STATUS_OFF']]
        )
    )
    ->setComment(new PhpComment(['Class Demo', '', '@see HelloWorld']));

file_put_contents('User.php', PhpRender::renderClass($class));

Result:, (*3)

<?php

namespace Demo;

use Rapture\Component\Definition\ClassAbstract;
use Rapture\Component\Definition\ClassInterface;
use Rapture\Component\Definition\ClassTrait;

/**
 * Class Demo
 * 
 * @see HelloWorld
 */
final abstract class Test extends ClassAbstract implements ClassInterface
{
    use ClassTrait;

    const STATUS_ON = 1;
    const STATUS_OFF = 2;

    protected $status = self::STATUS_OFF;

    public function setStatus(int $status = self::STATUS_OFF)
    {
        $this->status = $status;

        return $this;
    }
}

About

Author

Iulian N. rapture@iuliann.ro, (*4)

Testing

cd ./test && phpunit

License

Rapture PHP code Generator is licensed under the MIT License - see the LICENSE file for details., (*5)

The Versions

15/06 2017

dev-master

9999999-dev http://rapture.iuliann.ro

Rapture PHP generator component

  Sources   Download

MIT

The Requires

  • php >=7.0.4

 

library

15/06 2017

v1.0

1.0.0.0 http://rapture.iuliann.ro

Rapture PHP generator component

  Sources   Download

MIT

The Requires

  • php >=7.0.4

 

library