phplibrary/core/adapter.php
2016-07-14 16:29:26 +03:00

24 lines
No EOL
435 B
PHP

<?php
/**
* Интерфейс к массиву и обьекту как к коллекции
*/
class Adapter
{
protected $adaptee;
public function __construct ($adaptee)
{
$this->adaptee = $adaptee;
}
public function get ($name)
{
if (is_array ($this->adaptee)) {
return $this->adaptee [$name];
} else {
return $this->adaptee->$name;
}
}
}
?>