Created
August 12, 2020 20:57
-
-
Save erikfig/0a3030f7568084723a7d15d4e1e73f2d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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