PHP code example of lanfisis / deflection
1. Go to this page and download the library: Download lanfisis/deflection library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lanfisis / deflection example snippets
$transformer = new Deflection\Transformer();
$class = $transformer->arrayToClassElement(array(
'docblock' => array(
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
'infos' => array (
'category' => 'Deflection',
'author' => 'David Buros <[email protected] >',
'copyright' => '2014 David Buros',
'licence' => 'WTFPL see LICENCE.md file',
),
),
'namespace' => 'Deflection',
'uses' => array (
'Deflection\Element\Classes',
'Deflection\Element\Docblock',
'Method' => 'Deflection\Element\Functions',
),
'name' => 'Generator',
'extends' => 'GeneratorAbstract',
'implements' => array(
'ExtractorInterface',
'LimitIterator',
),
'functions' => array(
array(
'public' => true,
'name' => 'arrayToClassElement',
'docblock' => array(
'description' => 'Lorem ipsum dolor sit amet',
'params' => array (
'definition' => array(
'type' => 'array',
'description' => 'Lorem ipsum',
),
'is_active' => array(
'type' => 'boolean',
'description' => 'Lorem ipsum',
),
),
'return' => 'Deflection/Element/Functions',
),
'params' => array(
'definition' => 'array',
'is_active' => null,
),
'content' => array(
'if (1 == 1) {',
array('return new Method();'),
'}',
),
),
),
));
$generator = new Deflection\Generator($class);
echo($generator->asString());
/**
* Lorem ipsum dolor sit amet, consectetur adipiscing elit
*
* @category Deflection
* @author David Buros <[email protected] >
* @copyright 2014 David Buros
* @licence WTFPL see LICENCE.md file
*/
namespace Deflection;
use Deflection\Element\Classes;
use Deflection\Element\Docblock;
use Deflection\Element\Functions as Method;
class Generator
extends GeneratorAbstract
implements ExtractorInterface, LimitIterator
{
/**
* Lorem ipsum dolor sit amet
*
* @var array $definition Lorem ipsum
* @var boolean $is_active Lorem ipsum
*
* @return Deflection/Element/Functions
*/
public function arrayToClassElement(array $definition, $is_active)
{
if (1 == 1) {
return new Method();
}
}
}