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

AssetTransforms::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
ccs 19
cts 20
cp 0.95
rs 8.439
c 0
b 0
f 0
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\AssetTransform;
8
9
/**
10
 * Schematic Asset Transforms 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 AssetTransforms extends Base
21
{
22
    /**
23
     * Get all asset transforms
24 4
     *
25
     * @return AssetTransform[]
26 4
     */
27
    protected function getRecords()
28
    {
29
        return Craft::$app->assetTransforms->getAllTransforms();
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    protected function saveRecord(Model $record, array $definition)
36 3
    {
37
        $record->setAttributes($definition['attributes']);
38 3
    }
39
40 3
    /**
41
     * {@inheritdoc}
42 3
     */
43 2
    protected function deleteRecord(Model $record)
44 3
    {
45
        return Craft::$app->assetTransforms->deleteTransform($record);
46 3
    }
47
}
48