Completed
Push — master ( ec89fd...ab8bf4 )
by Jacob
04:45 queued 01:47
created

Embed::getCompositeKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
nc 1
cc 1
eloc 2
nop 0
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
     * {@inheritdoc}
37
     */
38
    public function getCompositeKey()
39
    {
40
        return spl_object_hash($this);
41
    }
42
43
    /**
44
     * Gets the metadata for this model.
45
     *
46
     * @api
47
     * @return  EmbedMetadata
48
     */
49
    public function getMetadata()
50
    {
51
        return $this->metadata;
52
    }
53
54
55
    /**
56
     * Gets the embed name.
57
     *
58
     * @api
59
     * @return  string
60
     */
61
    public function getName()
62
    {
63
        return $this->getMetadata()->name;
64
    }
65
}
66