tonicospinelli/classgeneration

Library to create Php Class files

Installs: 179

Dependents: 0

Stars: 9

Watches: 3

Forks: 4

Open Issues: 1

Language: PHP

2.2.1 2015-03-18 13:56 UTC

README

SensioLabsInsight Build Status Scrutinizer Quality Score Code Coverage

Latest Stable Version Total Downloads

Introduction

When I developed a specific project, I saw an opportunity to create a library to generate Php Class Files and this library was born.

Installation

I assume you know about Composer, if not look at Composer WebSite.

$ php composer.phar require tonicospinelli/classgeneration:2.2.*

OR

{
    "tonicospinelli/classgeneration" : "2.2.*"
}

QUICK START

ClassGeneration is simple to use. Here's a sample for creating a Php Class File.

<?php
require_once "../vendor/autoload.php";

use ClassGeneration\NamespaceClass;
use ClassGeneration\PhpClass;
use ClassGeneration\Property;
use ClassGeneration\Writer;

$code = new PhpClass();
$code
    ->setName('FirstClass')
    ->setNamespace(new NamespaceClass('MyNamespace'))
    ->setDescription('Class description')
    ->addProperty(new Property(array('name' => 'property')))
    ->generateGettersAndSettersFromProperties();

$writer = new Writer();
$writer
    ->setPhpClass($code)
    ->setPath('./src')
    ->write();

Result: ./src/MyNamespace/FirstClass.php

<?php

namespace MyNamespace;

/**
 * Class description
 * @name FirstClass
 */
class FirstClass
{

    public $property;

    public function getProperty()
    {
        return $this->property;
    }

    public function setProperty($property)
    {
        $this->property = $property;

        return $this;
    }
}

Version

2.2

MIT License

Free Software, Hell Yeah!