repo/includes/Api/FormatSnakValue.php
File FormatSnakValue.php
has 272 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
declare( strict_types = 1 );
namespace Wikibase\Repo\Api;
Method __construct
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
ApiMain $mainModule,
string $moduleName,
OutputFormatValueFormatterFactory $valueFormatterFactory,
OutputFormatSnakFormatterFactory $snakFormatterFactory,
DataTypeFactory $dataTypeFactory,
Method factory
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
ApiMain $mainModule,
string $moduleName,
IBufferingStatsdDataFactory $stats,
ApiHelperFactory $apiHelperFactory,
DataTypeFactory $dataTypeFactory,
Method getAllowedParams
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function getAllowedParams(): array {
return [
'generate' => [
ParamValidator::PARAM_TYPE => [
SnakFormatter::FORMAT_PLAIN,
Method getExamplesMessages
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function getExamplesMessages(): array {
$query = 'action=' . $this->getModuleName();
$hello = new StringValue( 'hello' );
$acme = new StringValue( 'http://acme.org' );
$einsteinDob = new TimeValue(
Method execute
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function execute(): void {
$this->getMain()->setCacheMode( 'public' );
$params = $this->extractRequestParams();
$this->requireMaxOneParameter( $params, 'property', 'datatype' );
Function getOptionsObject
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
private function getOptionsObject( ?string $optionsParam ): FormatterOptions {
$formatterOptions = new FormatterOptions();
$formatterOptions->setOption( ValueFormatter::OPT_LANG, $this->getLanguage()->getCode() );
if ( is_string( $optionsParam ) && $optionsParam !== '' ) {
- 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 formatValue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
private function formatValue( array $params, DataValue $value, ?string $dataTypeId ): string {
$snak = null;
if ( isset( $params['property'] ) ) {
$snak = new PropertyValueSnak( $this->parsePropertyId( $params['property'] ), $value );
}
- 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"