1. Go to this page and download the library: Download phoenixrvd/oda 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/ */
phoenixrvd / oda example snippets
class MyDataObject {
private $data = [];
public function getFoo(){
return $this->data['foo'];
}
public function setFoo($value){
$this->data['foo'] = $value;
return $this;
}
public function hasFoo(){
return isset($this->data['foo']);
}
public function isFoo($value){
return $this->hasFoo() && $this->data['foo'] === $value;
}
public function getBar(){
return $this->data['bar'];
}
public function setBar($value){
$this->data['bar'] = $value;
return $this;
}
public function hasBar(){
return isset($this->data['bar']);
}
public function isBar($value){
return $this->hasBar() && $this->data['bar'] === $value;
}
}
use PhoenixRVD\ODA\Interfaces\OdaObject;
use PhoenixRVD\ODA\Traits\DataAccessors;
use PhoenixRVD\ODA\Traits\ValueObject;
class MyDataObject implements OdaObject {
use ValueObject, DataAccessors;
}
use PhoenixRVD\ODA\Methods\AbstractMethod;
use PhoenixRVD\ODA\Interfaces\OdaObject;
class DateRFC822 extends AbstractMethod {
public function execute(OdaObject $object, array $attributes = array()) {
$data = $object->getData();
return date(DATE_RFC822, $data[ $this->propertyName ]);
}
}
use PhoenixRVD\ODA\MethodFactory;
trait MyObjectDecorator {
public function __call($name, $arguments) {
return (MethodFactory::getInstance())
->setAccessor(new DateRFC822) // Eigenes Accessor bei der Factory registrieren
->makeMethod($name)
->execute($this, $arguments);
}
}
use PhoenixRVD\ODA\Interfaces\OdaObject;
use PhoenixRVD\ODA\Traits\ValueObject;
class MyDataObject implements OdaObject {
use ValueObject, MyObjectDecorator;
}