Completed
Push — 4.9 ( f399a5...eb33e7 )
by Mikhail
01:38
created

AbstractController::getMethodName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace controllers;
4
5
abstract class AbstractController
6
{
7
    protected $config;
8
    protected $terminal;
9
    protected $filesystem;
10
11
    function __construct(
12
        \Config                 $config,
13
        \terminal\Terminal       $terminal,
14
        \filesystem\Filesystem   $filesystem
15
    )
16
    {
17
        $this->config               = $config;
18
        $this->terminal             = $terminal;
19
        $this->filesystem           = $filesystem;
20
    }
21
    
22
    /**
23
     * Returns array of methods that can be requested
24
     */
25
    abstract public static function getAllowedMethods(): array;
26
27
    /**
28
     * Get method name from terminal arguments
29
     * 
30
     * @return string
31
     */
32
    protected function getMethodName(): string
33
    {
34
        return $this->config->get('set')
35
            ? 'set' . ucfirst(to_camel_case($this->config->get('set')))
36
            : 'remove' . ucfirst(to_camel_case($this->config->get('remove')));
37
    }
38
}
39