Passed
Pull Request — master (#63)
by
unknown
04:39
created

SysLanguageRepository::findInstalledLanguages()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 15
nc 3
nop 0
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
1
<?php
2
namespace EWW\Dpf\Domain\Repository;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
/**
18
 * The repository for SysLanguage
19
 */
20
class SysLanguageRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Extbase\Persistence\Repository was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
{
22
23
    /**
24
     * Finds all installed languages of the TYPO3 system (usually on pid 0).
25
     *
26
     * @return \EWW\Dpf\Domain\Model\SysLanguage | NULL
27
     */
28
    public function findInstalledLanguages()
29
    {
30
        $result = $this->createQuery();
31
        $result->getQuerySettings()->setRespectStoragePage(false);
32
        $result->getQuerySettings()->setReturnRawQueryResult(true);
33
        $result->statement('SELECT l.uid,l.pid,l.title,l.flag,i.lg_iso_2 FROM sys_language as l LEFT JOIN static_languages as i ON i.uid = l.static_lang_isocode');
34
35
        if ($result->execute()) {
36
            foreach ($result->execute() as $language) {
37
                $sysLanguage = new \EWW\Dpf\Domain\Model\SysLanguage();
38
                $sysLanguage->setUid($language['uid']);
39
                $sysLanguage->setPid($language['pid']);
40
                $sysLanguage->setTitle($language['title']);
41
                $sysLanguage->setFlag($language['flag']);
42
                $sysLanguage->setLangIsocode(strtolower($language['lg_iso_2']));
43
44
                $sysLanguages[] = $sysLanguage;
45
            }
46
            return $sysLanguages;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $sysLanguages seems to be defined by a foreach iteration on line 36. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
47
        }
48
49
        return null;
50
    }
51
52
}
53