phplibrary/src/Adapter.php
2017-02-16 10:39:00 +03:00

22 lines
430 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;
}
}
}