for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types = 1);
/**
* Created by Vitaly Iegorov <[email protected]>.
* on 04.09.16 at 10:13
*/
namespace samsonphp\generator;
* Trait for generators that can generate internal code.
*
* @author Vitaly Egorov <[email protected]>
trait CodeTrait
{
/** @var array Collection of code lines */
protected $code = [];
* Add function code line.
* @param string $code Code line
* @return $this
public function defLine(string $code)
$this->code[] = $code;
return $this;
}
* Build arguments list with types.
* @param array $arguments Arguments collection
* @return string Arguments list
protected function buildArguments(array $arguments) : string
$argumentsString = [];
foreach ($arguments as $argumentName => $argumentType) {
// Group name with type
$argumentsString[] = ($argumentType !== null ? $argumentType . ' ' : '') . '$' . $argumentName;
return implode(', ', $argumentsString);