Completed
Push — master ( b1b281...32f961 )
by Sergi Tur
15s
created

src/Console/Routes/Controller.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Acacha\AdminLTETemplateLaravel\Console\Routes;
4
5
/**
6
 * Class Controller.
7
 *
8
 * @package Acacha\AdminLTETemplateLaravel\Console\Routes
9
 */
10
trait Controller
11
{
12
    /**
13
     * Obtain controller.
14
     *
15
     * @param $controllername
16
     * @return string
17
     */
18 View Code Duplication
    protected function controller($controllername)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
    {
20
        if (str_contains($controllername, '/')) {
21
            $controllername = str_replace('/', '\\', $controllername);
22
        }
23
24
        if (str_contains($controllername, '@')) {
25
            return ucfirst($controllername);
26
        }
27
        return ucfirst($controllername . '@index');
28
    }
29
30
    /**
31
     * Obtain controller.
32
     *
33
     * @param $controllername
34
     * @return string
35
     */
36 View Code Duplication
    protected function controllerWithoutMethod($controllername)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37
    {
38
        if (str_contains($controller = $controllername, '@')) {
39
            return ucfirst(substr($controllername, 0, strpos($controllername, '@')));
40
        }
41
        return ucfirst($controllername);
42
    }
43
44
    /**
45
     * Get method from controller name.
46
     *
47
     * @param $controllername
48
     * @return string
49
     */
50
    protected function controllerMethod($controllername)
51
    {
52
        if (str_contains($controller = $controllername, '@')) {
53
            return substr($controllername, strpos($controllername, '@')+1, strlen($controllername));
54
        }
55
        return 'index';
56
    }
57
}
58