Showing 57 of 591 total issues
Method translateTo
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function translateTo(string $languageCode, $amount = 1): string
{
$code = $this->getValue();
$translations = $this->getTranslations($languageCode);
/** @noinspection ExceptionsAnnotatingAndHandlingInspection */
Method fetchTranslations
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function fetchTranslations(): array
{
$translations = [
'cs' => [
'one' => [
Method getEnergeticSpellCodes
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function getEnergeticSpellCodes(): array
{
return [
self::MAROON,
self::BURN,
Method getMaterialSpellCodes
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function getMaterialSpellCodes(): array
{
return [
self::NOT_EVEN_HIT,
self::TODAY_YOU_WILL_TRY_IT_WITHOUT_WEAPON,
Method getInvestigativeSpellCodes
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function getInvestigativeSpellCodes(): array
{
return [
self::GOOD_TABLE,
self::WHERE_IS_MY_PIPE,
Method getMentalSpellCodes
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function getMentalSpellCodes(): array
{
return [
self::COLORS_AND_SHAPES,
self::ENJOY_YOURSELF,
Method getTimeSpaceSpellCodes
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function getTimeSpaceSpellCodes(): array
{
return [
self::MAGIC_ARMOR,
self::PROJECTILE,
Method getVitalSpellCodes
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function getVitalSpellCodes(): array
{
return [
self::QUINT_OF_SENSES,
self::TORTURE,
Method I_can_ask_code_if_is_specific_weapon_type
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function I_can_ask_code_if_is_specific_weapon_type()
{
$questions = [
'isBow', 'isCrossbow', 'isThrowingWeapon',
];
Method fetchTranslations
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function fetchTranslations(): array
{
return [
'en' => [
self::ASTRONOMY => [self::$ONE => 'astronomy'],
Method fetchTranslations
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function fetchTranslations(): array
{
return [
'en' => [
self::HORSE => [self::$ONE => 'horse', self::$FEW => 'horses', self::$MANY => 'horses'],
Method I_get_whispered_current_code_as_return_value_of_factory_method
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function I_get_whispered_current_code_as_return_value_of_factory_method()
{
foreach ($this->getCodeClasses() as $codeClass) {
$reflectionClass = new \ReflectionClass($codeClass);
$classBaseName = preg_replace('~^.*[\\\](\w+)$~', '$1', $codeClass);
Method getPossibleValues
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function getPossibleValues(): array
{
return [
self::BARRIER_VENUS,
self::BARRIER_MARS,
Method All_public_constants_can_be_given_by_getter
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function All_public_constants_can_be_given_by_getter()
{
$constants = $this->sutReflection->getConstants();
self::assertEquals($constants, array_unique($constants));
asort($constants);
Function getTranslations
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function getTranslations(string $requiredLanguageCode): array
{
if ((self::$translations[static::class] ?? null) === null) {
$translations = self::$customCodeTranslations[static::class] ?? [];
if (count($translations) === 0) {
- 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 I_can_get_all_codes_at_once_or_by_same_named_constant
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function I_can_get_all_codes_at_once_or_by_same_named_constant()
{
self::assertSame(
$expectedValues = [
// throwing weapons
Method getPossibleValues
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function getPossibleValues(): array
{
return [
self::ARMOR_WEARING,
self::ATHLETICS,
Method getRaceToSubRaceValues
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function getRaceToSubRaceValues(): array
{
return [
RaceCode::HUMAN => [
self::COMMON,
Method getExpectedRacesToSubRaces
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function getExpectedRacesToSubRaces(): array
{
return [
'human' => [
'common',
Method I_can_extended_it_by_custom_translatable_code
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function I_can_extended_it_by_custom_translatable_code()
{
/** @var WeaponCode $sutClass */
$sutClass = self::getSutClass();
$reflectionClass = new \ReflectionClass($sutClass);