Zone::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * @package Faker
5
 * @author Iurii Makukh <[email protected]>
6
 * @copyright Copyright (c) 2017, Iurii Makukh <[email protected]>
7
 * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License 3.0
8
 */
9
10
namespace gplcart\modules\faker\models\generators;
11
12
use gplcart\core\models\Zone as ZoneModel;
13
use gplcart\modules\faker\models\Generator as FakerModuleGenerator;
14
15
/**
16
 * Manages basic behaviors and data related to geo zones
17
 */
18
class Zone extends FakerModuleGenerator
19
{
20
21
    /**
22
     * Zone model class instance
23
     * @var \gplcart\core\models\Zone $zone
24
     */
25
    protected $zone;
26
27
    /**
28
     * @param ZoneModel $zone
29
     */
30
    public function __construct(ZoneModel $zone)
31
    {
32
        parent::__construct();
33
34
        $this->zone = $zone;
35
    }
36
37
    /**
38
     * Returns the generator name
39
     * @return string
40
     */
41
    public function getName()
42
    {
43
        return $this->translation->text('Zone');
44
    }
45
46
    /**
47
     * Generate a single zone
48
     * @return bool
49
     */
50
    public function create()
51
    {
52
        $data = array(
53
            'status' => $this->faker->boolean(),
54
            'title' => $this->faker->country() . ', ' . $this->faker->state()
55
        );
56
        return (bool) $this->zone->add($data);
57
    }
58
59
}
60