Completed
Push — master ( 3b0b6a...263c36 )
by Guillaume
02:53
created

SetupApikeySave::apikeySaved()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Godbout\Alfred\Time\Menus\Toggl;
4
5
use Godbout\Alfred\Time\Workflow;
6
use Godbout\Alfred\Workflow\Icon;
7
use Godbout\Alfred\Workflow\Item;
8
use Godbout\Alfred\Time\Menus\Menu;
9
use Godbout\Alfred\Workflow\ScriptFilter;
10
11 View Code Duplication
class SetupApikeySave extends Menu
0 ignored issues
show
Duplication introduced by Guillaume Leclerc
This class 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...
12
{
13
    public static function scriptFilter()
14
    {
15
        self::saveApikey();
16
17
        ScriptFilter::add(
18
            self::apikeySaved(),
19
            self::back()
20
        );
21
    }
22
23
    private static function saveApikey()
24
    {
25
        Workflow::getConfig()->write('toggl.api_token', getenv('toggl_apikey'));
26
    }
27
28
    private static function apikeySaved()
29
    {
30
        return Item::create()
31
            ->title('API KEY SAVED!')
32
            ->subtitle('You can just press Enter.')
33
            ->icon(Icon::create('resources/icons/toggl.png'))
34
            ->arg('do')
35
            ->variable('timer_action', 'exit');
36
    }
37
38
    private static function back()
39
    {
40
        return Item::create()
41
            ->title('Back')
42
            ->subtitle('Go back to Toggl Setup')
43
            ->arg('toggl_setup')
44
            ->icon(Icon::create('resources/icons/toggl.png'));
45
    }
46
}
47