factory() public static method

Static method to instantiate the property generator object and return itself to facilitate chaining methods together.
public static factory ( string $name, string $type, mixed $value = null, string $visibility = 'public' ) : PropertyGenerator
$name string
$type string
$value mixed
$visibility string
return PropertyGenerator
Example #1
0
 public function testRender()
 {
     $p = PropertyGenerator::factory('testProp', 'array', array(0, 1, 2));
     $this->assertContains('array', $p->render(true));
     $p = PropertyGenerator::factory('testProp', 'array', array('prop1' => 1, 'prop2' => 2));
     $this->assertContains('array', $p->render(true));
     $p = PropertyGenerator::factory('testProp', 'int', 0);
     $this->assertContains('int', $p->render(true));
     $p = PropertyGenerator::factory('testProp', 'boolean', true);
     $this->assertContains('boolean', $p->render(true));
     $p = PropertyGenerator::factory('testProp', 'string', 0, 'const');
     $this->assertContains('const', $p->render(true));
     $p = PropertyGenerator::factory('testProp', 'string', 123);
     $p = PropertyGenerator::factory('testProp', 'array');
     $p->setStatic(true);
     $this->assertTrue($p->isStatic());
     $codeStr = (string) $p;
     $code = $p->render(true);
     ob_start();
     $p->render();
     $output = ob_get_clean();
     $this->assertContains('static', $code);
     $this->assertContains('static', $codeStr);
     $this->assertContains('static', $output);
 }