Completed
Pull Request — master (#114)
by Bart
05:36
created

CategoryGroups::import()   B

Complexity

Conditions 6
Paths 10

Size

Total Lines 31
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 6.0045

Importance

Changes 0
Metric Value
dl 0
loc 31
rs 8.439
c 0
b 0
f 0
ccs 19
cts 20
cp 0.95
cc 6
eloc 17
nc 10
nop 2
crap 6.0045
1
<?php
2
3
namespace NerdsAndCompany\Schematic\Services;
4
5
use Craft;
6
use craft\base\Model;
7
use craft\models\CategoryGroup;
8
9
/**
10
 * Schematic Category Groups Service.
11
 *
12
 * Sync Craft Setups.
13
 *
14
 * @author    Nerds & Company
15
 * @copyright Copyright (c) 2015-2018, Nerds & Company
16
 * @license   MIT
17
 *
18
 * @see      http://www.nerds.company
19
 */
20
class CategoryGroups extends Base
21
{
22
    protected $recordClass = CategoryGroup::class;
23
24
    /**
25
     * Get all category groups
26
     *
27
     * @return CategoryGroup[]
28
     */
29 3
    protected function getRecords()
30
    {
31 3
        return Craft::$app->categories->getAllGroups();
32
    }
33 3
34
    /**
35 3
     * Save a record
36 2
     *
37 3
     * @param Model $record
38
     * @return boolean
39 3
     */
40
    protected function saveRecord(Model $record)
41
    {
42
        return Craft::$app->categories->saveGroup($record);
43
    }
44
45
    /**
46
     * Delete a record
47
     *
48
     * @param Model $record
49 4
     * @return boolean
50
     */
51 2
    protected function deleteRecord(Model $record)
52
    {
53
        return Craft::$app->categories->deleteGroup($record);
54 2
    }
55
}
56