Test Failed
Push — feature/job-builder/update-job... ( 68ba7e...7a08dc )
by Xander
23:02 queued 10:32
created

DepartmentController::index()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 15
ccs 11
cts 11
cp 1
rs 9.9332
cc 3
nc 3
nop 0
crap 3
1
<?php
2
3
namespace App\Http\Controllers\Api;
4
5
use App\Models\Lookup\Department;
6
use App\Http\Controllers\Controller;
7
8
class DepartmentController extends Controller
9
{
10
    /**
11
     * Return all skills as an array
12
     *
13
     * @return mixed
14
     */
15 1
    public function index()
16
    {
17 1
        $departments = Department::all();
18 1
        $departmentsTranslated = [];
19 1
        foreach ($departments as $department) {
20 1
            $deptArray = ['id' => $department->id];
21 1
            foreach (['en', 'fr'] as $locale) {
22 1
                $deptArray[$locale] = [
23 1
                    'name' => $department->getTranslation('name', $locale),
24 1
                    'impact' => $department->getTranslation('impact', $locale),
25
                ];
26
            }
27 1
            $departmentsTranslated[] = $deptArray;
28
        }
29 1
        return $departmentsTranslated;
30
    }
31
}
32