HasMany::build()   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 namespace AdamWathan\Faktory\Relationship;
2
3
class HasMany extends DependentRelationship
4
{
5
    protected $quantity;
6
7
    public function __construct($related_model, $factoryLoader, $quantity, $foreign_key = null, $attributes = [])
8
    {
9
        parent::__construct($related_model, $factoryLoader, $foreign_key, $attributes);
10
        $this->quantity = $quantity;
11
    }
12
13
    public function build()
14
    {
15
        return $this->factory->buildMany($this->quantity, $this->attributes);
16
    }
17
18
    protected function createRelated()
19
    {
20
        return $this->factory->createMany($this->quantity, $this->attributes);
21
    }
22
23
    public function quantity($quantity)
24
    {
25
        $this->quantity = $quantity;
26
        return $this;
27
    }
28
}
29