gluon-web-remote

Web remote Administration for big size of gluon routers
git clone git://archive.git.mtrnord.blog/MTRNord/gluon-web-remote.git
Log | Files | Refs | README

AbstractResourceHolder.php (727B)


      1 <?php
      2 
      3 namespace Ssh;
      4 
      5 use RuntimeException;
      6 
      7 /**
      8  * An abstract resource holder
      9  *
     10  * @author Antoine Hérault <antoine.herault@gmail.com>
     11  */
     12 abstract class AbstractResourceHolder implements ResourceHolder
     13 {
     14     protected $resource;
     15 
     16     /**
     17      * Returns the underlying resource. If the resource does not exist, it will
     18      * create it
     19      *
     20      * @return resource
     21      */
     22     public function getResource()
     23     {
     24         if (!is_resource($this->resource)) {
     25             $this->createResource();
     26         }
     27 
     28         return $this->resource;
     29     }
     30 
     31     /**
     32      * Creates the underlying resource
     33      *
     34      * @throws RuntimeException on resource creation failure
     35      */
     36     abstract protected function createResource();
     37 }