Example #1
0
 /**
  * @param mixed $source
  * @throws \Exception
  */
 public function __construct($source)
 {
     $this->source = $source;
     if ($source instanceof File) {
         $this->data = array('url' => site_url($source->path . '/' . $source->fullname), 'path' => realpath(APPPATH . '../' . $source->path . '/' . $source->fullname));
     } elseif (is_array($source)) {
         $this->data = array('url' => \Kohana_Arr::getValidate($source, 'url', null, function ($val) {
             if (!is_string($val)) {
                 throw new \Exception(__METHOD__ . ' url must be a string.');
             }
             return true;
         }), 'path' => \Kohana_Arr::getValidate($source, 'path', null, function ($val) {
             if (!is_string($val)) {
                 throw new \Exception(__METHOD__ . ' path must be a string.');
             }
             return true;
         }));
     } else {
         throw new \Exception('Invalid source given. Expected array or \\File ' . gettype($source) . ' given.');
     }
 }