Completed
Push — master ( e24a08...649c71 )
by Joshua
9s
created

Embed   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 3
c 3
b 1
f 0
lcom 0
cbo 3
dl 0
loc 45
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getMetadata() 0 4 1
A getName() 0 4 1
1
<?php
2
3
namespace As3\Modlr\Models;
4
5
use As3\Modlr\Metadata\EmbedMetadata;
6
use As3\Modlr\Store\Store;
7
8
/**
9
 * Represents an embedded record fragment of a root level model.
10
 *
11
 * @author Jacob Bare <[email protected]>
12
 */
13
class Embed extends AbstractModel
14
{
15
    /**
16
     * The metadata that defines this Model.
17
     *
18
     * @var EmbedMetadata
19
     */
20
    protected $metadata;
21
22
    /**
23
     * Constructor.
24
     *
25
     * @param   EmbedMetadata   $metadata   The internal embed metadata that supports this Embed.
26
     * @param   Store           $store      The model store service for handling persistence operations.
27
     * @param   array|null      $properties The embed's properties from the db layer to init the embed with. New embeds will constructed with a null record.
28
     */
29
    public function __construct(EmbedMetadata $metadata, Store $store, array $properties = null)
30
    {
31
        parent::__construct($metadata, $store, $properties);
32
        $this->getState()->setLoaded();
33
    }
34
35
    /**
36
     * Gets the metadata for this model.
37
     *
38
     * @api
39
     * @return  EmbedMetadata
40
     */
41
    public function getMetadata()
42
    {
43
        return $this->metadata;
44
    }
45
46
47
    /**
48
     * Gets the embed name.
49
     *
50
     * @api
51
     * @return  string
52
     */
53
    public function getName()
54
    {
55
        return $this->getMetadata()->name;
56
    }
57
}
58