Method getOperationSystemName
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getOperationSystemName()
{
$typeId = OsInfo::os();
$labels = array(
Avoid using static access to class '\loophp\phposinfo\OsInfo' in method 'getOperationSystemTypeCode'. Open
strtolower(OsInfo::os())
- 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 '\loophp\phposinfo\OsInfo' in method 'getOperationSystemName'. Open
$typeId = OsInfo::os();
- 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 '\loophp\phposinfo\OsInfo' in method '__construct'. Open
OsInfo::register();
- 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 '\loophp\phposinfo\OsInfo' in method 'getOperationSystemFamily'. Open
$familyId = OsInfo::family(); // phpcs:ignore PHPCompatibility.Extensions.RemovedExtensions
- 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
Define a constant instead of duplicating this literal "mingw" 3 times. Open
OsName::MINGW => 'mingw',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "cygwin" 4 times. Open
OsName::CYGWIN => 'cygwin',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "windows" 5 times. Open
OsName::WIN32 => 'windows',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Reference to constant HPUX
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::HPUX => 'unix',
- Exclude checks
Reference to constant WINDOWS
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::WINDOWS => 'windows',
- Exclude checks
Reference to constant WINDOWS
from undeclared class \loophp\phposinfo\Enum\FamilyName
Open
FamilyName::WINDOWS => 'windows',
- Exclude checks
Call to method register
from undeclared class \loophp\phposinfo\OsInfo
Open
OsInfo::register();
- Exclude checks
Reference to constant DARWIN
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::DARWIN => 'mac',
- Exclude checks
Reference to constant NETBSD
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::NETBSD => 'bsd',
- Exclude checks
Reference to constant MINIX
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::MINIX => 'unix',
- Exclude checks
Reference to constant SUNOS
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::SUNOS => 'sun',
- Exclude checks
Reference to constant MINGW
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::MINGW => 'mingw',
- Exclude checks
Reference to constant MINGW32NT61
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::MINGW32NT61 => 'mingw',
- Exclude checks
Reference to constant AIX
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::AIX => 'unix',
- Exclude checks
Reference to constant SCOSV
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::SCOSV => 'unix',
- Exclude checks
Call to method os
from undeclared class \loophp\phposinfo\OsInfo
Open
$typeId = OsInfo::os();
- Exclude checks
Reference to constant DEBIANFREEBSD
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::DEBIANFREEBSD => 'bsd',
- Exclude checks
Reference to constant WIN32
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::WIN32 => 'windows',
- Exclude checks
Reference to constant CYGWIN
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::CYGWIN => 'cygwin',
- Exclude checks
Reference to constant UNIXWARE
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::UNIXWARE => 'unix',
- Exclude checks
Reference to constant LINUX
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::LINUX => 'linux',
- Exclude checks
Reference to constant CYGWINNT61
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::CYGWINNT61 => 'cygwin',
- Exclude checks
Reference to constant CYGWINNT51
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::CYGWINNT51 => 'cygwin',
- Exclude checks
Reference to constant ULTRIX
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::ULTRIX => 'unix',
- Exclude checks
Reference to constant OPENBSD
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::OPENBSD => 'bsd',
- Exclude checks
Reference to constant SINIXY
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::SINIXY => 'unix',
- Exclude checks
Reference to constant UWINW7
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::UWINW7 => 'unix',
- Exclude checks
Reference to constant DRAGONFLY
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::DRAGONFLY => 'bsd',
- Exclude checks
Reference to constant WINDOWSNT
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::WINDOWSNT => 'windows',
- Exclude checks
Reference to constant LINUX
from undeclared class \loophp\phposinfo\Enum\FamilyName
Open
FamilyName::LINUX => 'unix',
- Exclude checks
Reference to constant SOLARIS
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::SOLARIS => 'solaris',
- Exclude checks
Reference to constant CYGWINNT61WOW64
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::CYGWINNT61WOW64 => 'cygwin',
- Exclude checks
Reference to constant BSD
from undeclared class \loophp\phposinfo\Enum\FamilyName
Open
FamilyName::BSD => 'unix',
- Exclude checks
Reference to constant OSF1
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::OSF1 => 'unix',
- Exclude checks
Reference to constant QNX
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::QNX => 'unix',
- Exclude checks
Reference to constant RELIANTUNIXY
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::RELIANTUNIXY => 'unix',
- Exclude checks
Reference to constant MSYSNT61
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::MSYSNT61 => 'mingw'
- Exclude checks
Call to method os
from undeclared class \loophp\phposinfo\OsInfo
Open
strtolower(OsInfo::os())
- Exclude checks
Reference to constant FREEBSD
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::FREEBSD => 'bsd',
- Exclude checks
Reference to constant GNUFREEBSD
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::GNUFREEBSD => 'bsd',
- Exclude checks
Reference to constant GNULINUX
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::GNULINUX => 'linux',
- Exclude checks
Reference to constant WINNT
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::WINNT => 'windows',
- Exclude checks
Call to method family
from undeclared class \loophp\phposinfo\OsInfo
Open
$familyId = OsInfo::family(); // phpcs:ignore PHPCompatibility.Extensions.RemovedExtensions
- Exclude checks
Reference to constant GNU
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::GNU => 'unix',
- Exclude checks
Reference to constant UWIN
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::UWIN => 'unix',
- Exclude checks
Reference to constant ZOS
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::ZOS => 'zos',
- Exclude checks
Reference to constant DARWIN
from undeclared class \loophp\phposinfo\Enum\FamilyName
Open
FamilyName::DARWIN => 'unix',
- Exclude checks
Reference to constant UNIX_ON_WINDOWS
from undeclared class \loophp\phposinfo\Enum\FamilyName
Open
FamilyName::UNIX_ON_WINDOWS => 'windows-unix'
- Exclude checks
Reference to constant GNUKFREEBSD
from undeclared class \loophp\phposinfo\Enum\OsName
Open
OsName::GNUKFREEBSD => 'bsd',
- Exclude checks