Completed
Push — master ( 00ac10...57b531 )
by Filipe
03:06
created

Entity   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 62.5%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 3
c 3
b 0
f 1
lcom 0
cbo 3
dl 0
loc 39
ccs 5
cts 8
cp 0.625
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A save() 0 6 1
A delete() 0 5 1
A getMapper() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of slick/orm package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Orm;
11
12
use Slick\Common\Base;
13
14
/**
15
 * Entity
16
 *
17
 * @package Slick\Orm
18
 * @readwrite
19
 */
20
abstract class Entity extends Base implements EntityInterface
21
{
22
23
    /**
24
     * Saves current entity state
25
     *
26
     * Optionally saves only the partial data if $data argument is passed. If
27
     * no data is given al the field properties will be updated.
28
     *
29
     * @param array $data Partial data to save
30
     *
31
     * @return mixed
32
     */
33 2
    public function save(array $data = [])
34
    {
35 2
        return $this->getMapper()
36 2
            ->save($this, $data);
37
38
    }
39
40
    /**
41
     * Deletes current entity from its storage
42
     *
43
     * @return self|$this|EntityInterface
44
     */
45
    public function delete()
46
    {
47
        return $this->getMapper()
48
            ->delete($this);
49
    }
50
51
    /**
52
     * Retrieves the data mapper for this entity
53
     */
54 2
    public function getMapper()
55
    {
56 2
        return Orm::getMapper(get_class($this));
57
    }
58
}