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

Volumes   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 41
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getRecords() 0 4 1
A saveRecord() 0 4 1
A deleteRecord() 0 4 1
1
<?php
2
3
namespace NerdsAndCompany\Schematic\Services;
4
5
use Craft;
6
use craft\base\VolumeInterface;
7
use craft\base\Model;
8
use craft\volumes\Local;
9
use NerdsAndCompany\Schematic\Schematic;
10
11
/**
12
 * Schematic Asset Sources Service.
13
 *
14
 * Sync Craft Setups.
15
 *
16
 * @author    Nerds & Company
17
 * @copyright Copyright (c) 2015-2018, Nerds & Company
18
 * @license   MIT
19
 *
20
 * @see      http://www.nerds.company
21
 */
22
class Volumes extends Base
23
{
24
    /**
25
     * The record class
26
     * @TODO: export to schema file
27
     * @var string
28
     */
29
    protected $recordClass = Local::class;
30
31
    /**
32
     * Get all asset transforms
33
     *
34
     * @return VolumeInterface[]
35
     */
36
    protected function getRecords()
37
    {
38
        return Craft::$app->volumes->getAllVolumes();
39
    }
40
41
    /**
42
     * Save a record
43
     *
44
     * @param Model $record
45
     * @return boolean
46
     */
47
    protected function saveRecord(Model $record)
48
    {
49
        return Craft::$app->volumes->saveVolume($record);
50
    }
51
52
    /**
53
     * Delete a record
54
     *
55
     * @param Model $record
56
     * @return boolean
57
     */
58
    protected function deleteRecord(Model $record)
59
    {
60
        return Craft::$app->volumes->deleteVolume($record);
61
    }
62
}
63