Consider simplifying this complex logical expression. Open
if (
// Apple iOS 3.2-5.1 - Tested on the original iPad (4.3 / 5.0), iPad 2 (4.3), iPad 3 (5.1), original iPhone (3.1), iPhone 3 (3.2), 3GS (4.3), 4 (4.3 / 5.0), and 4S (5.1)
$this->isIOS() && $this->version('iPad', self::VERSION_TYPE_FLOAT)>=4.3 ||
$this->isIOS() && $this->version('iPhone', self::VERSION_TYPE_FLOAT)>=3.1 ||
$this->isIOS() && $this->version('iPod', self::VERSION_TYPE_FLOAT)>=3.1 ||
File Mobile_Detect.php
has 561 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Mobile Detect Library
* =====================
*
Function mobileGrade
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
public function mobileGrade()
{
$isMobile = $this->isMobile();
if (
- 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 (
$this->isIOS() && $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 ||
$this->isIOS() && $this->version('iPhone', self::VERSION_TYPE_FLOAT)<3.1 ||
$this->isIOS() && $this->version('iPod', self::VERSION_TYPE_FLOAT)<3.1 ||
Mobile_Detect
has 31 functions (exceeds 20 allowed). Consider refactoring. Open
class Mobile_Detect
{
/**
* Mobile detection type.
*
Function checkHttpHeadersForMobile
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function checkHttpHeadersForMobile()
{
foreach($this->getMobileHeaders() as $mobileHeader => $matchType){
if( isset($this->httpHeaders[$mobileHeader]) ){
- 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 mobileGrade
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function mobileGrade()
{
$isMobile = $this->isMobile();
if (
Function version
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function version($propertyName, $type = self::VERSION_TYPE_STRING)
{
if (empty($propertyName)) {
return false;
}
- 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 setUserAgent
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function setUserAgent($userAgent = null)
{
if (!empty($userAgent)) {
return $this->userAgent = $userAgent;
} else {
- 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 matchDetectionRulesAgainstUA
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function matchDetectionRulesAgainstUA($userAgent = null)
{
// Begin general search.
foreach ($this->getRules() as $_regex) {
if (empty($_regex)) {
- 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"