/
dimamir
/
Wsdl_PackageGenerator
Обзор
Документация
Войти
/
dimamir
/
Wsdl_PackageGenerator
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/File/AbstractFile.php
74 строки
2 KB
Mikaël DELSOL
issue #124 - implement PHP >= 7.4 tasks
01 мар 2021, 22:36
01 мар 2021, 22:36
8447c9b
Код
Авторство
О чём код?
<?php declare(strict_types=1); namespace WsdlToPhp\PackageGenerator\File; use WsdlToPhp\PackageGenerator\Generator\Generator; use WsdlToPhp\PhpGenerator\Component\PhpFile; abstract class AbstractFile implements FileInterface { public const PHP_FILE_EXTENSION = 'php'; protected Generator $generator; protected PhpFile $file; public function __construct(Generator $generator, string $name) { $this ->setFile(new PhpFile($name)) ->setGenerator($generator) ; } public function setGenerator(Generator $generator): self { $this->generator = $generator; return $this; } public function getGenerator(): Generator { return $this->generator; } public function write(): void { $this->writeFile(); } public function getFileName(): string { return sprintf('%s%s.%s', $this->getFileDestination(), $this->getFile()->getMainElement()->getName(), $this->getFileExtension()); } public function getFileExtension(): string { return self::PHP_FILE_EXTENSION; } public function getFile(): PhpFile { return $this->file; } protected function writeFile(): void { file_put_contents($this->getFileName(), $this->getFile()->toString(), LOCK_EX); } protected function getFileDestination(): string { return $this->getGenerator()->getOptionDestination(); } protected function setFile(PhpFile $file): self { $this->file = $file; return $this; } }