Function expand
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
public function expand( string $url, $defaultProto = PROTO_FALLBACK ): ?string {
if ( $defaultProto === PROTO_CANONICAL ) {
$serverUrl = $this->canonicalServer;
} elseif ( $defaultProto === PROTO_INTERNAL ) {
$serverUrl = $this->internalServer;
- 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 removeDotSegments
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public static function removeDotSegments( string $urlPath ): string {
$output = '';
$inputOffset = 0;
$inputLength = strlen( $urlPath );
- 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
File UrlUtils.php
has 283 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace MediaWiki\Utils;
use BadMethodCallException;
Method removeDotSegments
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function removeDotSegments( string $urlPath ): string {
$output = '';
$inputOffset = 0;
$inputLength = strlen( $urlPath );
Method expand
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function expand( string $url, $defaultProto = PROTO_FALLBACK ): ?string {
if ( $defaultProto === PROTO_CANONICAL ) {
$serverUrl = $this->canonicalServer;
} elseif ( $defaultProto === PROTO_INTERNAL ) {
$serverUrl = $this->internalServer;
Function assemble
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static function assemble( array $urlParts ): string {
$result = '';
if ( isset( $urlParts['delimiter'] ) ) {
if ( isset( $urlParts['scheme'] ) ) {
- 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 assemble
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function assemble( array $urlParts ): string {
$result = '';
if ( isset( $urlParts['delimiter'] ) ) {
if ( isset( $urlParts['scheme'] ) ) {
Function __construct
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function __construct( array $options = [] ) {
foreach ( $options as $key => $value ) {
switch ( $key ) {
case self::SERVER:
case self::CANONICAL_SERVER:
- 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 parse
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function parse( string $url ): ?array {
// Protocol-relative URLs are handled really badly by parse_url(). It's so bad that the
// easiest way to handle them is to just prepend 'http:' and strip the protocol out later.
$wasRelative = str_starts_with( $url, '//' );
if ( $wasRelative ) {
- 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 matchesDomainList
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function matchesDomainList( string $url, array $domains ): bool {
$bits = $this->parse( $url );
if ( is_array( $bits ) && isset( $bits['host'] ) ) {
$host = '.' . $bits['host'];
foreach ( $domains as $domain ) {
- 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"