whiteCube/lingua

View on GitHub

Showing 36 of 36 total issues

File languages.php has 2216 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
 
/**
* This file should always return an array containing
* the languages data. Please follow the structure
Severity: Major
Found in languages.php - About 6 days to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    <?php
     
    namespace WhiteCube\Lingua;
     
    class W3cConverter extends ComponentConverter implements ConverterInterface
    Severity: Major
    Found in src/Lingua/W3cConverter.php and 1 other location - About 6 hrs to fix
    src/Lingua/PhpConverter.php on lines 1..26

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    <?php
     
    namespace WhiteCube\Lingua;
     
    class PhpConverter extends ComponentConverter implements ConverterInterface
    Severity: Major
    Found in src/Lingua/PhpConverter.php and 1 other location - About 6 hrs to fix
    src/Lingua/W3cConverter.php on lines 1..26

    Function find has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    public static function find($format, $value)
    {
    $instance = self::getInstance();
    foreach ($instance->languages as $language) {
    if(!isset($language[$format])) continue;
    Severity: Minor
    Found in src/Lingua/LanguagesRepository.php - About 1 hr to fix

    The class Iso_639_2tConverter is not named in CamelCase.
    Open

    class Iso_639_2tConverter extends Converter implements ConverterInterface
    {
    public static function check($format)
    {
    if(preg_match('/^([A-Za-z]{3})$/', static::prepare($format))) return true;
    Severity: Minor
    Found in src/Lingua/Iso_639_2tConverter.php by phpmd

    The class Iso_639_2bConverter is not named in CamelCase.
    Open

    class Iso_639_2bConverter extends Converter implements ConverterInterface
    {
    public static function check($format)
    {
    if(preg_match('/^([A-Za-z]{3})$/', static::prepare($format))) return true;
    Severity: Minor
    Found in src/Lingua/Iso_639_2bConverter.php by phpmd

    The class Iso_639_3Converter is not named in CamelCase.
    Open

    class Iso_639_3Converter extends Converter implements ConverterInterface
    {
    public function __toString()
    {
    $string = $this->original['code'] ?? $this->original['full'];
    Severity: Minor
    Found in src/Lingua/Iso_639_3Converter.php by phpmd

    The class Iso_639_1Converter is not named in CamelCase.
    Open

    class Iso_639_1Converter extends Converter implements ConverterInterface
    {
    public static function check($format)
    {
    if(preg_match('/^([A-Za-z]{2})$/', static::prepare($format))) return true;
    Severity: Minor
    Found in src/Lingua/Iso_639_1Converter.php by phpmd

    Function guess has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    protected function guess(string $format)
    {
    $matches = [];
    foreach (self::$converters as $key => $converter) {
    if(!call_user_func_array($converter . '::check', [$format])) continue;
    Severity: Minor
    Found in src/Lingua/Service.php - About 45 mins to fix

    Function format has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    public static function format(ConverterInterface $converter)
    {
    if(!$converter->repository) {
    throw new \Exception('Language "' . $converter . '" could not be converted to its english name since it is not registered in the Lingua repository');
    }
    Severity: Minor
    Found in src/Lingua/NameConverter.php - About 35 mins to fix

    Missing class import via use statement (line '105', column '23').
    Open

    throw new \Exception('Instantiation methods should begin with "create"');
    Severity: Minor
    Found in src/Lingua/Service.php by phpmd

    Missing class import via use statement (line '51', column '21').
    Open

    $item = new \stdClass();
    Severity: Minor
    Found in src/Lingua/Converter.php by phpmd

    Missing class import via use statement (line '33', column '23').
    Open

    throw new \Exception('Language "' . $converter . '" could not be converted to its native name since it is not registered in the Lingua repository');
    Severity: Minor
    Found in src/Lingua/NativeConverter.php by phpmd

    Missing class import via use statement (line '64', column '19').
    Open

    throw new \Exception('Call to undefined Lingua method "' . $method . '"');
    Severity: Minor
    Found in src/Lingua/Service.php by phpmd

    Remove error control operator '@' on line 59.
    Open

    protected function loadRepository()
    {
    if(false === @file_get_contents($this->path)) {
    throw new \Exception('Lingua\'s languages repository could not be loaded');
    }
    Severity: Minor
    Found in src/Lingua/LanguagesRepository.php by phpmd

    Missing class import via use statement (line '16', column '23').
    Open

    throw new \Exception('Unable to find language named "' . $this->original . '"');
    Severity: Minor
    Found in src/Lingua/NameConverter.php by phpmd

    Missing class import via use statement (line '122', column '23').
    Open

    throw new \Exception('Call to undefined "'. $prefix . '" Lingua method');
    Severity: Minor
    Found in src/Lingua/Service.php by phpmd

    Missing class import via use statement (line '60', column '23').
    Open

    throw new \Exception('Lingua\'s languages repository could not be loaded');
    Severity: Minor
    Found in src/Lingua/LanguagesRepository.php by phpmd

    Missing class import via use statement (line '33', column '23').
    Open

    throw new \Exception('Language "' . $converter . '" could not be converted to its english name since it is not registered in the Lingua repository');
    Severity: Minor
    Found in src/Lingua/NameConverter.php by phpmd

    Missing class import via use statement (line '16', column '23').
    Open

    throw new \Exception('Unable to find native language named "' . $this->original . '"');
    Severity: Minor
    Found in src/Lingua/NativeConverter.php by phpmd
    Severity
    Category
    Status
    Source
    Language