mirror of
https://github.com/Ne-Lexa/php-zip.git
synced 2025-10-11 13:24:28 +02:00
php cs fix
This commit is contained in:
@@ -11,23 +11,22 @@ use PhpZip\ZipFileInterface;
|
||||
*/
|
||||
class ZipNewEntry extends ZipAbstractEntry
|
||||
{
|
||||
/**
|
||||
* @var resource|string|null
|
||||
*/
|
||||
/** @var resource|string|null */
|
||||
protected $content;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
|
||||
/** @var bool */
|
||||
private $clone = false;
|
||||
|
||||
/**
|
||||
* ZipNewEntry constructor.
|
||||
*
|
||||
* @param string|resource|null $content
|
||||
*/
|
||||
public function __construct($content = null)
|
||||
{
|
||||
parent::__construct();
|
||||
if ($content !== null && !is_string($content) && !is_resource($content)) {
|
||||
|
||||
if ($content !== null && !\is_string($content) && !\is_resource($content)) {
|
||||
throw new InvalidArgumentException('invalid content');
|
||||
}
|
||||
$this->content = $content;
|
||||
@@ -36,16 +35,18 @@ class ZipNewEntry extends ZipAbstractEntry
|
||||
/**
|
||||
* Returns an string content of the given entry.
|
||||
*
|
||||
* @return null|string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getEntryContent()
|
||||
{
|
||||
if (is_resource($this->content)) {
|
||||
if (\is_resource($this->content)) {
|
||||
if (stream_get_meta_data($this->content)['seekable']) {
|
||||
rewind($this->content);
|
||||
}
|
||||
|
||||
return stream_get_contents($this->content);
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
@@ -57,18 +58,19 @@ class ZipNewEntry extends ZipAbstractEntry
|
||||
public function getVersionNeededToExtract()
|
||||
{
|
||||
$method = $this->getMethod();
|
||||
return self::METHOD_WINZIP_AES === $method ? 51 :
|
||||
|
||||
return $method === self::METHOD_WINZIP_AES ? 51 :
|
||||
(
|
||||
ZipFileInterface::METHOD_BZIP2 === $method ? 46 :
|
||||
$method === ZipFileInterface::METHOD_BZIP2 ? 46 :
|
||||
(
|
||||
$this->isZip64ExtensionsRequired() ? 45 :
|
||||
(ZipFileInterface::METHOD_DEFLATED === $method || $this->isDirectory() ? 20 : 10)
|
||||
$this->isZip64ExtensionsRequired() ? 45 :
|
||||
($method === ZipFileInterface::METHOD_DEFLATED || $this->isDirectory() ? 20 : 10)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone extra fields
|
||||
* Clone extra fields.
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
@@ -78,7 +80,7 @@ class ZipNewEntry extends ZipAbstractEntry
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
if (!$this->clone && $this->content !== null && is_resource($this->content)) {
|
||||
if (!$this->clone && $this->content !== null && \is_resource($this->content)) {
|
||||
fclose($this->content);
|
||||
$this->content = null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user