File Zebra_Image.php
has 574 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Methods used with the {@link resize()} method.
*/
Method resize
has 189 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function resize($width = 0, $height = 0, $method = ZEBRA_IMAGE_CROP_CENTER, $background_color = -1)
{
// if image resource was successfully created
if ($this->_create_from_source()) {
// if either width or height is to be adjusted automatically
Function resize
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
public function resize($width = 0, $height = 0, $method = ZEBRA_IMAGE_CROP_CENTER, $background_color = -1)
{
// if image resource was successfully created
if ($this->_create_from_source()) {
// if either width or height is to be adjusted automatically
- 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 apply_filter
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public function apply_filter($filter, $arg1 = '', $arg2 = '', $arg3 = '', $arg4 = '')
{
// if "imagefilter" function exists and the requested filter exists
if (function_exists('imagefilter')) // if image resource was successfully created
{
- 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
Consider simplifying this complex logical expression. Open
if (
// aspect ratio needs to be preserved AND
($this->preserve_aspect_ratio || isset($auto_preserve_aspect_ratio))
&& // both width and height are given
Function _create_from_source
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
private function _create_from_source()
{
// perform some error checking first
// if the GD library is not installed
if (!function_exists('gd_info')) {
- 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 rotate
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function rotate($angle, $background_color = -1)
{
// get function arguments
$arguments = func_get_args();
- 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 _create_from_source
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function _create_from_source()
{
// perform some error checking first
// if the GD library is not installed
if (!function_exists('gd_info')) {
Method _flip
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function _flip($orientation)
{
// if image resource was successfully created
if ($this->_create_from_source()) {
// prepare the target image
Function _write_image
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function _write_image($identifier)
{
// sharpen image if it's required
$this->_sharpen_image($identifier);
- 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 _write_image
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function _write_image($identifier)
{
// sharpen image if it's required
$this->_sharpen_image($identifier);
Method rotate
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function rotate($angle, $background_color = -1)
{
// get function arguments
$arguments = func_get_args();
Consider simplifying this complex logical expression. Open
if ($width == 0 && $height > 0) {
// get the original image's aspect ratio
$aspect_ratio = $this->source_width / $this->source_height;
// the target image's height is as given as argument to the method
Method apply_filter
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function apply_filter($filter, $arg1 = '', $arg2 = '', $arg3 = '', $arg4 = '')
{
// if "imagefilter" function exists and the requested filter exists
if (function_exists('imagefilter')) // if image resource was successfully created
{
Method crop
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function crop($start_x, $start_y, $end_x, $end_y)
{
// this method might be also called internally
// in this case, there's a fifth argument that points to an already existing image identifier
$args = func_get_args();
Method apply_filter
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function apply_filter($filter, $arg1 = '', $arg2 = '', $arg3 = '', $arg4 = '')
Avoid too many return
statements within this method. Open
return $this->crop(
$target_width - $width,
floor(($target_height - $height) / 2),
$target_width,
Avoid too many return
statements within this method. Open
return $this->crop(
floor(($target_width - $width) / 2),
$target_height - $height,
floor(($target_width - $width) / 2) + $width,
Avoid too many return
statements within this method. Open
return $this->crop(
$target_width - $width,
$target_height - $height,
$target_width,
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $this->_write_image($target_identifier);
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $this->crop(
floor(($target_width - $width) / 2),
floor(($target_height - $height) / 2),
floor(($target_width - $width) / 2) + $width,
Avoid too many return
statements within this method. Open
return $this->crop(
0,
$target_height - $height,
$width,
Avoid too many return
statements within this method. Open
return $this->_write_image($target_identifier);
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;