gossi\codegen\model\PhpConstant::create PHP Method

create() public static method

Creates a new PHP constant
public static create ( string $name = null, mixed $value = null, boolean $isExpression = false ) : static
$name string
$value mixed
$isExpression boolean
return static
    public static function create($name = null, $value = null, $isExpression = false)
    {
        return new static($name, $value, $isExpression);
    }

Usage Example

 public function testExpression()
 {
     $class = new PhpClass('ClassWithExpression');
     $class->setConstant(PhpConstant::create('FOO', 'BAR'))->setProperty(PhpProperty::create('bembel')->setExpression("['ebbelwoi' => 'is eh besser', 'als wie' => 'bier']"))->setMethod(PhpMethod::create('getValue')->addParameter(PhpParameter::create('arr')->setExpression('[self::FOO => \'baz\']')));
     $codegen = new CodeFileGenerator(['generateDocblock' => false]);
     $code = $codegen->generate($class);
     $this->assertEquals($this->getGeneratedContent('ClassWithExpression.php'), $code);
 }
All Usage Examples Of gossi\codegen\model\PhpConstant::create