Method getCanonical
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getCanonical( string $name, string $validate = self::RIGOR_VALID ) {
// Force usernames to capital
$name = $this->contentLang->ucfirst( $name );
// Reject names containing '#'; these will be cleaned up
Method isValid
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function isValid( string $name ): bool {
if ( $name === ''
|| $this->isIP( $name )
|| $this->isValidIPRange( $name )
|| $this->isLikeIPv4DashRange( $name )
Function isUsable
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function isUsable( string $name ): bool {
// Must be a valid username, obviously ;)
if ( !$this->isValid( $name ) ) {
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
Consider simplifying this complex logical expression. Open
if ( $name === ''
|| $this->isIP( $name )
|| $this->isValidIPRange( $name )
|| $this->isLikeIPv4DashRange( $name )
|| str_contains( $name, '/' )
Method __construct
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
ServiceOptions $options,
Language $contentLang,
LoggerInterface $logger,
TitleParser $titleParser,
ITextFormatter $textFormatter,
Function getCanonical
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getCanonical( string $name, string $validate = self::RIGOR_VALID ) {
// Force usernames to capital
$name = $this->contentLang->ucfirst( $name );
// Reject names containing '#'; these will be cleaned up
- 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 $this->isUsable( $name ) ? $name : false;
Avoid too many return
statements within this method. Open
return $this->isCreatable( $name ) ? $name : false;
Function isValid
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function isValid( string $name ): bool {
if ( $name === ''
|| $this->isIP( $name )
|| $this->isValidIPRange( $name )
|| $this->isLikeIPv4DashRange( $name )
- 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"