Completed
Pull Request — develop (#41)
by
unknown
04:01
created

Controller   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 17
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getEncouragementText() 0 15 6
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use Illuminate\Foundation\Bus\DispatchesJobs;
6
use Illuminate\Routing\Controller as BaseController;
7
use Illuminate\Foundation\Validation\ValidatesRequests;
8
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
9
10
class Controller extends BaseController
11
{
12
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
13
14
    /**
15
     * Indicates wether the application operates in sharing mode.
16
     *
17
     * @var boolean
18
     */
19
    protected $sharingMode = false;
20
21
22
    /**
23
     * Create a new controller instance.
24
     */
25
    public function __construct()
26
    {
27
        view()->share(['sharingMode' => $this->sharingMode]);
28
    }
29
30
    public function getEncouragementText($total_prs)
31
    {
32
        if ($total_prs >= config('settings.required_prs'))
33
            $encouragement_message = "Congrats, you're done!";
34
        elseif ($total_prs == 1)
35
            $encouragement_message = "A good start, just keep doing.";
36
        elseif ((int) (config('settings.required_prs') / $total_prs) == 2 )
37
            $encouragement_message = "Almost halfway there, keep doing.";
38
        elseif ((config('settings.required_prs') / $total_prs) == 2)
39
            $encouragement_message = "You're halfway there, keep doing!";
40
        elseif ((config('settings.required_prs') - $total_prs) == 2)
41
            $encouragement_message = "Only 2 left, let's keep doing.";
42
        else
43
            $encouragement_message = "You're almost done.";
44
        return $encouragement_message;
45
    }
46
}
47