http://modulesgarden.com * CONTACT -> contact@modulesgarden.com * * * This software is furnished under a license and may be used and copied * only in accordance with the terms of such license and with the * inclusion of the above copyright notice. This software or any other * copies thereof may not be provided or otherwise made available to any * other person. No title to and ownership of the software is hereby * transferred. * * * ******************************************************************** */ namespace MGProvision\Proxmox\v2\repository; /** * Description of AbstractRepository * * @author Pawel Kopec * @version 1.0.0 */ Abstract class AbstractRepository { protected $api; protected $fetch; public function setApi($api) { $this->api = $api; } /** * * @return \MGProvision\Proxmox\v2\Api */ protected function api() { if ($this->api !== null) return $this->api; return $this->api = \MGProvision\Proxmox\v2\Api::getInstance(); } abstract public function fetch(); public function fetchArray() { $data = array(); foreach ($this->fetch() as $entity) { $data[] = $entity->toArray(); } return $data; } public function reset() { $this->fetch = null; return $this; } public function count() { return count($this->fetch()); } }