Completed
Pull Request — dev (#330)
by Josh
06:54
created

ApplicationTrackerComposer::compose()   A

Complexity

Conditions 5
Paths 3

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 22
ccs 0
cts 13
cp 0
rs 9.5555
c 0
b 0
f 0
cc 5
nc 3
nop 1
crap 30
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace App\Http\ViewComposers;
4
5
use Illuminate\View\View;
6
use Illuminate\Support\Facades\Lang;
7
use App\Models\JobApplication;
8
9
class ApplicationTrackerComposer
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ApplicationTrackerComposer
Loading history...
10
{
11
    /**
12
     * Bind data to the view.
13
     *
14
     * @param  View  $view
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
15
     * @return void
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
16
     */
17
    public function compose(View $view)
18
    {
19
        $app_tracker = Lang::get('applicant/application_tracker');
20
21
22
        $app_tracker['items']['basics']['url'] = route('job.application.edit.1', $view->getData()['job']);
23
        $app_tracker['items']['experience']['url'] = route('job.application.edit.2', $view->getData()['job']);
24
        $app_tracker['items']['essential_skills']['url'] = route('job.application.edit.3', $view->getData()['job']);
25
        $app_tracker['items']['asset_skills']['url'] = route('job.application.edit.4', $view->getData()['job']);
26
        $app_tracker['items']['preview']['url'] = route('job.application.edit.5', $view->getData()['job']);
27
28
        //TODO: all these checks shouldn't be neccessary when controllers are properly set up
29
        if (isset($view->getData()['job_application'])) {
30
            $job_application = $view->getData()['job_application'];
31
            if ($job_application != null && $job_application instanceof JobApplication) {
32
                foreach($app_tracker['items'] as $key => $value) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
33
                    $app_tracker['items'][$key]['status'] = $job_application->getSectionStatus($key);
34
                }
35
            }
36
        }
37
38
        $view->with('application_tracker', $app_tracker);
39
    }
40
}
41