save accesses the super-global variable $_POST. Open
public static function save(array $files, array $remove = array())
{
$page = Page::html();
if (($retrieve = $page->post('retrieve')) && isset($files[$retrieve])) {
exit(is_file($files[$retrieve]) ? file_get_contents($files[$retrieve]) : '');
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Function view
has a Cognitive Complexity of 107 (exceeds 5 allowed). Consider refactoring. Open
public static function view($dir, array $extensions = array(), $recursive = false)
{
extract(Admin::params(array('bp', 'blog', 'auth', 'page', 'website')));
$dir = rtrim($dir, '/').'/';
- 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 view
has 272 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function view($dir, array $extensions = array(), $recursive = false)
{
extract(Admin::params(array('bp', 'blog', 'auth', 'page', 'website')));
$dir = rtrim($dir, '/').'/';
File Files.php
has 584 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace BootPress\Admin;
use BootPress\Blog\Twig\Parser;
Function save
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
public static function save(array $files, array $remove = array())
{
$page = Page::html();
if (($retrieve = $page->post('retrieve')) && isset($files[$retrieve])) {
exit(is_file($files[$retrieve]) ? file_get_contents($files[$retrieve]) : '');
- 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 image
has 114 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function image($path, $eject = '')
{
$html = '';
$imagick = (extension_loaded('imagick') && class_exists('Imagick')) ? true : false;
$types = array('jpg', 'gif', 'png');
Function iterate
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public static function iterate($path, $recursive = false, $types = null)
{
$dirs = $files = array();
if (is_dir($path)) {
$cut = strlen($path);
- 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 save
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function save(array $files, array $remove = array())
{
$page = Page::html();
if (($retrieve = $page->post('retrieve')) && isset($files[$retrieve])) {
exit(is_file($files[$retrieve]) ? file_get_contents($files[$retrieve]) : '');
Method iterate
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function iterate($path, $recursive = false, $types = null)
{
$dirs = $files = array();
if (is_dir($path)) {
$cut = strlen($path);
Function image
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private static function image($path, $eject = '')
{
$html = '';
$imagick = (extension_loaded('imagick') && class_exists('Imagick')) ? true : false;
$types = array('jpg', 'gif', 'png');
- 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 resource
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static function resource($path)
{
if (preg_match('/\.(jpg|jpeg|gif|png|ico)$/i', $path) && is_file($path) && ($dimensions = getimagesize($path))) {
list($width, $height, $type) = $dimensions;
switch ($type) {
- 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
Avoid too many return
statements within this method. Open
return $page->sendJson($data);
Avoid too many return
statements within this method. Open
return '<div id="admin_manage_files">'.$files.'</div><br>'.$form;
Function format
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function format($path, $slashes = false, $capitals = false)
{
if ($capitals === false) {
$path = strtolower($path);
}
- 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 view() contains an exit expression. Open
exit('success');
- Read upRead up
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
The method view() contains an exit expression. Open
exit('error');
- Read upRead up
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
The method save() contains an exit expression. Open
exit(is_file($files[$retrieve]) ? file_get_contents($files[$retrieve]) : '');
- Read upRead up
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
The method save() contains an exit expression. Open
exit(preg_replace('#'.str_replace('/', '[\\\\//]{1}', preg_quote($linter)).'#', str_replace('.php', '', $save).'.php', $output));
- Read upRead up
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
The method save() contains an exit expression. Open
exit($e->getMessage());
- Read upRead up
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
The method save() contains an exit expression. Open
exit('Saved');
- Read upRead up
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
The method save() contains an exit expression. Open
exit('This file is not writable');
- Read upRead up
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
The method save() contains an exit expression. Open
exit(preg_replace('#'.str_replace('/', '[\\\\//]{1}', preg_quote($linter)).'#', str_replace('.ini', '', $save).'.ini', $e->getMessage()));
- Read upRead up
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
The method save() contains an exit expression. Open
exit('There was an error');
- Read upRead up
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
The method save() contains an exit expression. Open
exit($e->getMessage());
- Read upRead up
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
The method save() contains an exit expression. Open
exit('Saved');
- Read upRead up
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
The CASE body must start on the line following the statement Open
case 3: $type = 'png'; break;
- Exclude checks
The CASE body must start on the line following the statement Open
case 2: $type = 'jpg'; break;
- Exclude checks
Each PHP statement must be on a line by itself Open
case 1: $type = 'gif'; break;
- Exclude checks
Each PHP statement must be on a line by itself Open
case 3: $type = 'png'; break;
- Exclude checks
The CASE body must start on the line following the statement Open
case 17: $type = 'ico'; break;
- Exclude checks
The CASE body must start on the line following the statement Open
case 1: $type = 'gif'; break;
- Exclude checks
Each PHP statement must be on a line by itself Open
case 2: $type = 'jpg'; break;
- Exclude checks
Terminating statement must be on a line by itself Open
case 3: $type = 'png'; break;
- Exclude checks
Terminating statement must be on a line by itself Open
case 1: $type = 'gif'; break;
- Exclude checks
Each PHP statement must be on a line by itself Open
case 17: $type = 'ico'; break;
- Exclude checks
Terminating statement must be on a line by itself Open
case 17: $type = 'ico'; break;
- Exclude checks
Terminating statement must be on a line by itself Open
case 2: $type = 'jpg'; break;
- Exclude checks
Closing brace must be on a line by itself Open
case 3: $type = 'png'; break;
- Exclude checks
Closing brace must be on a line by itself Open
case 17: $type = 'ico'; break;
- Exclude checks
Closing brace must be on a line by itself Open
case 2: $type = 'jpg'; break;
- Exclude checks
Closing brace must be on a line by itself Open
case 1: $type = 'gif'; break;
- Exclude checks