PopulateZonedShippingTask   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 17
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 11 2
1
<?php
2
3
/**
4
 * @package silvershop-shipping
5
 */
6
class PopulateZonedShippingTask extends BuildTask
7
{
8
    protected $title = "Populate Zoned Shipping Methods";
9
    protected $description = 'If no zoned shipping methods exist, it creates some.';
10
11
    public function run($request = null)
12
    {
13
        if (!DataObject::get_one('ZonedShippingMethod')) {
14
            $factory = Injector::inst()->create('FixtureFactory');
15
            $fixture = new YamlFixture('silvershop-shipping/tests/fixtures/ZonedShippingMethod.yml');
16
            $fixture->writeInto($factory);
17
            DB::alteration_message('Created zoned shipping methods', 'created');
18
        } else {
19
            DB::alteration_message('Some zoned shipping methods already exist. None were created.');
20
        }
21
    }
22
}
23
24
/**
25
 * Makes PopulateZonedShippingTask get run before PopulateShopTask is run
26
 *
27
 * @package silvershop-shipping
28
 */
29
class PopulateShopZonedShippingTask extends Extension
30
{
31
    public function beforePopulate()
32
    {
33
        $task = new PopulateZonedShippingTask();
34
        $task->run();
35
    }
36
}
37