@ 2017-07-09T19:34:46Z <?php
class Object {
//
protected $hasMany;
protected $theSignificativeProperties = ['nome', 'login'];
public function getHasMany() {
return $this->hasMany;
}
public function getSignificativeProperties() {
return $this->theSignificativeProperties;
}
}
class Aluno extends Object {
private $nome;
private $login;
protected $hasMany = ['post', 'disciplina'];
protected $theSignificativeProperties = ['nome', 'login'];
/*public function getHasMany() {
return $this->hasMany;
}*/
/*public function getSignificativeProperties() {
return $this->theSignificativeProperties;
}*/
}
class Post extends Object {
//
}
class Disciplina extends Object {
protected $hasMany = ['aluno'];
}
class EntityManager {
//
}
class RelationalEntityManager extends EntityManager {
public function find($array) {
//
echo 'Usando o RelationalEntityManager. ';
echo 'Vou fazer JOIN com ';
print_r($array);
$query = 'SELECT';
return $query;
}
}
class BaseController {
protected $objectService;
protected $model;
public function __construct($modelName) {
$this->model = $modelName;
$this->objectService = new BaseObjectService($modelName, new RelationalEntityManager());
}
public function view() {
$args = func_get_args();
$this->objectService->view($args);
}
}
class AlunoController extends BaseController {
}
class DisciplinaController extends BaseController {
}
class BaseObjectService {
protected $em;
protected $model;
public function __construct($modelName, EntityManager $entityManager) {
$this->model = $modelName;
$this->em = $entityManager;
}
public function view($args) {
//
echo 'Argumentos: ';
print_r($args);
echo 'Classe em questão: ' . $this->model;
echo ' -> Propriedades: ';
$reflect = new ReflectionClass(ucfirst($this->model));
// $props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED);
$props = $reflect->getProperties();
foreach ($props as $prop) {
print $prop->getN ame() . ", ";
}
$methods = $reflect->getMethods();
$array = array();
foreach ($methods as $method) {
print $method->getName() . ", ";
if ( $method->getName() == 'getHasMany') {
echo 'achou o HASMANY de ' . $this->model ;
//print_r($reflect->getHasMany());
$hasManyMethod = $reflect->getMethod('getHasMany');
$c = ucfirst($this->model);
$x = new $c();
$array = $hasManyMethod->invoke($x);
print_r($array);
}
}
echo ' --- ';
// var_dump($props);
$results = $this->em->find($array);
$data['results'] = $results;
$this->render($this->model, 'view', $data);
}
public function render($controller, $action, $data) {
extract($data);
echo 'require ' . $controller . '/' . $action . 'view.php';
echo 'dados recebidos: ';
print_r($data);
}
}
// echo 'Aluno: ' . class_exists('Aluno') . '<br>';
// echo 'Teste: '; var_dump(class_exists('Teste')) . '\n';
// $a = new Aluno();
// print_r ( $a->getSignificativeProperties() );
$alunoController = new AlunoController('aluno');
$alunoController->view('marcelo', 'boi', 1);
$disciplinaController = new DisciplinaController('disciplina');
$disciplinaController->view('PHP', 55);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.1.7 0.006 0.012 16.65 7.1.6 0.023 0.020 34.94 7.1.5 0.024 0.018 34.80 7.1.4 0.012 0.018 34.21 7.1.3 0.014 0.014 34.39 7.1.2 0.028 0.021 34.51 7.1.1 0.007 0.007 16.48 7.1.0 0.008 0.005 16.29 7.0.20 0.014 0.004 16.49 7.0.19 0.003 0.014 16.46 7.0.18 0.012 0.003 16.09 7.0.17 0.012 0.003 16.01 7.0.16 0.007 0.007 16.12 7.0.15 0.009 0.009 16.00 7.0.14 0.007 0.011 16.07 7.0.13 0.006 0.009 16.23 7.0.12 0.003 0.012 16.23 7.0.11 0.006 0.009 16.02 7.0.10 0.000 0.015 16.16 7.0.9 0.007 0.007 16.01 7.0.8 0.009 0.006 15.93 7.0.7 0.003 0.010 16.04 7.0.6 0.003 0.010 15.95 7.0.5 0.010 0.003 16.17 7.0.4 0.003 0.011 16.38 7.0.3 0.005 0.009 16.49 7.0.2 0.000 0.012 16.30 7.0.1 0.007 0.007 16.44 7.0.0 0.005 0.010 16.18
preferences:dark mode live preview
142.1 ms | 1386 KiB | 7 Q