TranslationListCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
dl 0
loc 38
ccs 0
cts 26
cp 0
rs 10
c 1
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A translations() 0 3 1
A configure() 0 5 1
A __construct() 0 6 1
A execute() 0 12 2
1
<?php
2
3
namespace FaizShukri\Quran\Commands;
4
5
use FaizShukri\Quran\Supports\Config;
6
use FaizShukri\Quran\Repositories\Source\XMLRepository;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
class TranslationListCommand extends Command
12
{
13
    private $source;
14
15
    private $config;
16
17
    public function __construct()
18
    {
19
        parent::__construct();
20
        $this->config = new Config;
21
        $this->source = new XMLRepository;
22
        $this->source->setConfig($this->config);
23
    }
24
25
    protected function configure()
26
    {
27
        $this
28
            ->setName('translation:list')
29
            ->setDescription('View available translations');
30
    }
31
32
    protected function execute(InputInterface $input, OutputInterface $output): int
33
    {
34
        $translations = $this->translations();
35
36
        $output->writeln("<info>Available translations. (For usage, you can use short form, example: </info>en <info>instead of</info> en.sahih <info>)</info>");
37
        foreach ($translations as $translation) {
38
            $output->writeln("  - <comment>$translation</comment>");
39
        }
40
41
        $output->writeln("");
42
43
        return 0;
44
    }
45
46
    private function translations()
47
    {
48
        return $this->config->get('translations');
49
    }
50
}
51