Esempio n. 1
0
 /**
  * @test
  * @covers Cocur\Ea\PropertyFactory::generate()
  * @covers Cocur\Ea\PropertyFactory::generateDefault()
  */
 public function generateGeneratesCodeForPropertyWithDefaultEmptyArrayValue()
 {
     $p = new PropertyFactory('foo');
     $p->setDefault([]);
     $this->assertSame('public $foo = [];', $p->generate());
 }
Esempio n. 2
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use Cocur\Ea\ClassFactory;
use Cocur\Ea\Ea;
use Cocur\Ea\PropertyFactory;
$name = PropertyFactory::create('name', 'private');
Ea::create()->addClass(ClassFactory::create('Foo', 'Foobar')->addProperty($name)->addGetter($name)->addSetter($name))->execute();
$foo = new Foobar\Foo();
$foo->setName('Florian');
echo "name: " . $foo->getName() . "\n";
Esempio n. 3
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use Cocur\Ea\ClassFactory;
use Cocur\Ea\Ea;
use Cocur\Ea\PropertyFactory;
Ea::create()->addClass(ClassFactory::create('Foo', 'Foobar')->addProperty(PropertyFactory::create('foo')))->execute();
$foo = new Foobar\Foo();
$foo->foo = 'foo';
echo "foo? foo=" . $foo->foo . "\n";