2018-06-11 15:10:07 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tainacan\Tests\Factories;
|
|
|
|
|
|
|
|
class Metadatum_Factory {
|
|
|
|
private $metadatum;
|
2018-06-11 17:57:50 +00:00
|
|
|
protected $metadata_type;
|
2018-06-11 15:10:07 +00:00
|
|
|
|
|
|
|
public function create_metadatum($type, $primitive_type = []){
|
|
|
|
if(empty($type)){
|
|
|
|
throw new \InvalidArgumentException('The type can\'t be empty');
|
|
|
|
} elseif(!strrchr($type, '_')){
|
|
|
|
$type = ucfirst(strtolower($type));
|
|
|
|
} else {
|
|
|
|
$type = ucwords(strtolower($type), '_');
|
|
|
|
}
|
|
|
|
|
2018-06-11 17:57:50 +00:00
|
|
|
$this->metadata_type = "\Tainacan\Metadata_Types\\$type";
|
|
|
|
$this->metadatum = new $this->metadata_type(/* Here goes the primitive type */);
|
2018-06-11 15:10:07 +00:00
|
|
|
|
|
|
|
return $this->metadatum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|