/** * @see \WsdlToPhp\PackageGenerator\File\AbstractFile::writeFile() * @param bool $withSrc * @return int|bool */ public function writeFile($withSrc = true) { if (!$this->getModel() instanceof AbstractModel) { throw new \InvalidArgumentException('You MUST define the model before begin able to generate the file', __LINE__); } GeneratorUtils::createDirectory($this->getFileDestination($withSrc)); $this->defineNamespace()->defineUseStatement()->addAnnotationBlock()->addClassElement(); return parent::writeFile(); }
/** * @throws \InvalidArgumentException * @return Generator */ protected function initDirectory() { Utils::createDirectory($this->getOptions()->getDestination()); if (!is_writable($this->getOptionDestination())) { throw new \InvalidArgumentException(sprintf('Unable to use dir "%s" as dir does not exists, its creation has been impossible or it\'s not writable', $this->getOptionDestination()), __LINE__); } return $this; }
/** * @expectedException \InvalidArgumentException */ public function testExceptionOntInitDirectory() { Utils::createDirectory($destination = self::getTestDirectory() . 'notwritable', 0444); $generator = self::getBingGeneratorInstance(); $generator->setOptionComposerName('wsdltophp/invalid')->setOptionDestination($destination); $generator->generatePackage(); }