HasMany   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 26
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A build() 0 4 1
A createRelated() 0 4 1
A quantity() 0 5 1
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