Skip to content

Instantly share code, notes, and snippets.

@erikfig
Created August 12, 2020 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikfig/0a3030f7568084723a7d15d4e1e73f2d to your computer and use it in GitHub Desktop.
Save erikfig/0a3030f7568084723a7d15d4e1e73f2d to your computer and use it in GitHub Desktop.
<?php
class Model {
public static function find($name)
{
return 'Model::find::' . $name;
}
public function save()
{
return 'Model';
}
}
class Repository {
public static function __callStatic($name, $arguments)
{
return call_user_func_array([new Model, $name], $arguments);
}
public function __call($name, $arguments)
{
return call_user_func_array([new Model, $name], $arguments);
}
public function __set($name, $value)
{
$this->$name = $value;
}
public function __get($name)
{
return 'Erik';
}
}
echo Repository::save();
echo PHP_EOL;
echo (new Repository)->find('Thalisson');
$repo = new Repository;
$repo->name = 'Thalisson';
echo PHP_EOL;
echo $repo->melhorDevDaWebjump;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment