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

Entity::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
ccs 0
cts 3
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 2
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
}