Function unzip
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function unzip($toDir, bool $close = true)
{
if (\is_string($toDir)) {
$toDir = [$toDir];
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method unzip
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function unzip($toDir, bool $close = true)
{
if (\is_string($toDir)) {
$toDir = [$toDir];
}
Function validateFile
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function validateFile(string $path)
{
if (!Validator::path($path)) {
return true;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function extract
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function extract(string $toDir)
{
if (!is_dir($toDir) && !mkdir($toDir, 0755, true) && !is_dir($toDir)) {
throw new \App\Exceptions\AppException('Directory unable to create it');
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
The method unzip() has an NPath complexity of 296. The configured NPath complexity threshold is 200. Open
public function unzip($toDir, bool $close = true)
{
if (\is_string($toDir)) {
$toDir = [$toDir];
}
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method unzip() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10. Open
public function unzip($toDir, bool $close = true)
{
if (\is_string($toDir)) {
$toDir = [$toDir];
}
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Refactor this function to reduce its Cognitive Complexity from 27 to the 15 allowed. Open
public function unzip($toDir, bool $close = true)
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Missing class import via use statement (line '147', column '14'). Open
throw new \App\Exceptions\AppException('Directory unable to create it');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '266', column '16'). Open
$files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '58', column '14'). Open
throw new \App\Exceptions\AppException('Unable to open the zip file');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '61', column '14'). Open
throw new \App\Exceptions\AppException('The content of the zip file is too large');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '82', column '14'). Open
throw new \App\Exceptions\AppException('Unable to create the zip file');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '266', column '47'). Open
$files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '54', column '14'). Open
throw new \App\Exceptions\AppException('No file name');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method unzip has a boolean flag argument $close, which is a certain sign of a Single Responsibility Principle violation. Open
public function unzip($toDir, bool $close = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method addDirectory has a boolean flag argument $relativePath, which is a certain sign of a Single Responsibility Principle violation. Open
public function addDirectory(string $dir, string $localName = '', bool $relativePath = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method openFile has a boolean flag argument $fileName, which is a certain sign of a Single Responsibility Principle violation. Open
public static function openFile($fileName = false, $options = [])
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Avoid using static access to class 'App\Fields\File' in method 'addDirectory'. Open
$zipPath = str_replace(\DIRECTORY_SEPARATOR, '/', Fields\File::getLocalPath($filePath, $pathToTrim));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Fields\File' in method 'validateFile'. Open
$fileInstance = \App\Fields\File::loadFromInfo([
'content' => $this->getFromName($path),
'path' => $this->getLocalPath($path),
'name' => basename($path),
'size' => $stat['size'],
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Validator' in method 'validateFile'. Open
if (!Validator::path($path)) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Argument 1 (source)
is true
but \App\Zip::open()
takes string
Open
if (!file_exists($fileName) || !$zip->open($fileName)) {
- Exclude checks
Call with 2 arg(s) to \App\Zip::__construct()
which only takes 0 arg(s) defined at /code/app/Zip.php:18
Open
$zip = new self($fileName, $options);
- Exclude checks
Argument 1 (filename)
is true
but \file_exists()
takes string
Open
if (!file_exists($fileName) || !$zip->open($fileName)) {
- Exclude checks
Call to method path
from undeclared class \App\Validator
(Did you mean class \Tests\App\Validator) Open
if (!Validator::path($path)) {
- Exclude checks
Avoid variables with short names like $df. Configured minimum length is 3. Open
$df = disk_free_space(ROOT_DIRECTORY . \DIRECTORY_SEPARATOR);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Spaces must be used to indent lines; tabs are not allowed Open
* Check files before unpacking.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException('The content of the zip file is too large');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($created[$fileDir])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Open file for create zip file.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $close
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $illegalExtensions;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $zip;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip = new self($fileName, $options);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to extract files.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
for ($i = 0; $i < $this->numFiles; ++$i) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $checkFiles = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool|Zip
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $options
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return \App\Zip
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function openFile($fileName = false, $options = [])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function createFile($fileName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException('Unable to create the zip file');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param $toDir Target directory
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string|string[] Unpacked files
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zipPath = $this->getNameIndex($i);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($data = fread($fpr, 1024)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!is_dir($fileDir)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Open file and initialization unpack.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$fileName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$zip->checkFreeSpace()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ((!\is_numeric($dir) && 0 !== strpos($path, $dir . '/')) || $this->validateFile($zipPath)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$files[] = $zipPath;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip->{$key} = $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function unzip($toDir, bool $close = true)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$path = \str_replace('\\', '/', $zipPath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
fclose($fpw);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Illegal extensions for extract.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\AppException
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($toDir as $dir => $target) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
continue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->isDir($path)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fpw = fopen($file, 'w');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $fileName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
fwrite($fpw, $data);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Files extension for extract.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip = new self();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (true !== $zip->open($fileName, self::CREATE | self::OVERWRITE)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$file = $target . '/' . (\is_numeric($dir) ? $path : substr($path, \strlen($dir) + 1));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($options as $key => $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$toDir = [$toDir];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
fclose($fpr);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $onlyExtensions;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException('Unable to open the zip file');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fpr = $this->getStream($zipPath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!file_exists($fileName) || !$zip->open($fileName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $fileName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_string($toDir)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($close) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fileList;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Check free disk space.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$localName .= '/';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zipPath = str_replace(\DIRECTORY_SEPARATOR, '/', Fields\File::getLocalPath($filePath, $pathToTrim));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $name
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws Exceptions\AppException
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileDir = \dirname($file);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
mkdir($fileDir, 0755, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$created[$fileDir] = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Read from Zip and write to disk
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function extract(string $toDir)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!Validator::path($path)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$filePath = $file->getRealPath();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $files;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
continue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Push out the file content for download.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException('No file name');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $zip;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$files = $created = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get compressed file path.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Simple extract the archive contents.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Check illegal characters.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->checkFiles && !$this->isDir($path)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('/' === substr($filePath, -1, 1)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return copy($this->getLocalPath($compressedFileName), $targetFileName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Copy the directory on the disk into zip file.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $localName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$pathToTrim = $relativePath ? $path : ROOT_DIRECTORY;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($this->illegalExtensions) && \in_array($extension, $this->illegalExtensions)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'name' => basename($path),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $filePath
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $targetFileName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$size = 0;
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
$files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException('Directory unable to create it');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$validate = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'content' => $this->getFromName($path),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'path' => $this->getLocalPath($path),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'validateAllCodeInjection' => true,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function unzipFile($compressedFileName, $targetFileName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $relativePath
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$file->isDir()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function download(string $name)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->validateFile(\str_replace('\\', '/', $path))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->extractTo($toDir, $fileList);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$validate = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Check if the file path is directory.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileName = $this->filename;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$extension = pathinfo($path, PATHINFO_EXTENSION);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return "zip://{$this->filename}#{$compressedFileName}";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $dir
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($localName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$path = $this->getNameIndex($i);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function validateFile(string $path)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($this->onlyExtensions) && !\in_array($extension, $this->onlyExtensions)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
for ($i = 0; $i < $this->numFiles; ++$i) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('cache-control: private, max-age=120, must-revalidate');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileList = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$fileInstance->validate()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\AppException
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $path
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$stat = $this->statName($path);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileInstance = \App\Fields\File::loadFromInfo([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'size' => $stat['size'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function isDir($filePath)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $compressedFileName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
for ($i = 0; $i < $this->numFiles; ++$i) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileList[] = $path;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getLocalPath($compressedFileName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function checkFreeSpace()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$stat = $this->statIndex($i);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($files as $file) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->addFile($filePath, $localName . $zipPath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $toDir
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $validate;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $compressedFileName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$size += $stat['size'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('pragma: no-cache');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$df = disk_free_space(ROOT_DIRECTORY . \DIRECTORY_SEPARATOR);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function addDirectory(string $dir, string $localName = '', bool $relativePath = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('expires: 0');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unlink($fileName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('content-disposition: attachment; filename="' . $name . '.zip";');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!is_dir($toDir) && !mkdir($toDir, 0755, true) && !is_dir($toDir)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$validate = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$validate = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to extract single file.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $df > $size;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$path = realpath($dir);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('content-length: ' . filesize($fileName));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('content-type: application/zip');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('accept-ranges: bytes');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
readfile($fileName);
- Exclude checks