/** * Getter * * @param string $name * * @return mixed */ public function __get($name) { switch ($name) { case 'distributor': return Distributor::get($this->id); break; default: return null; break; } }
/** * Copy file * * @param string $id * @param string $src * @param string $dist_name * @return string item's relative path * * @throws DuplicateException * @throws CompileException */ public function copy($id, $src, $dist_name = '') { if (!file_exists($src)) { throw new CompileException(sprintf('%s doesn\'t exist.', $src)); } if (!$dist_name) { $dist_name = basename($src); } if (!isset(static::$ids[$id])) { static::$ids[$id] = []; } if (false !== array_search($dist_name, static::$ids[$id])) { throw new DuplicateException(sprintf('%s is not unique for ePub(%s).', $dist_name, $id)); } static::$ids[$id][] = $dist_name; $distributor = Distributor::get($id); // Move file $rel_path = $this->directory . DIRECTORY_SEPARATOR . $dist_name; $distributor->copy($src, $rel_path); // Return ID return $rel_path; }
/** * @param string $name * * @return mixed|null * @throws SettingException */ public function __get($name) { switch ($name) { case 'container': $class_name = 'Hametuha\\HamePub\\MetaInf\\' . ucfirst($name); return $class_name::get($this->id); break; case 'parser': return HTML5Parser::get($this->id); break; case 'opf': return Content::get($this->id); break; case 'toc': return Toc::get($this->id) ?: Toc::init($this->id, 'Index'); break; case 'distributor': return Distributor::get($this->id); break; default: return null; break; } }
/** * Set up test stui */ protected function setUp() { // Set distributor $this->distributor = Distributor::get($this->id, $this->tmp_dir); }