Completed
Branch feature/pre-split (d91fae)
by Anton
05:19
created

RecordMapper   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 91
rs 10
wmc 8
lcom 1
cbo 2

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getTable() 0 4 1
A getDatabase() 0 4 1
A insert() 0 4 1
A update() 0 4 1
A delete() 0 4 1
A dbalTable() 0 4 1
A dbalDatabase() 0 4 1
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
namespace Spiral\ORM\Entities;
9
10
use Spiral\Database\Entities\Database;
11
use Spiral\Database\Entities\Table;
12
use Spiral\ORM\ORMInterface;
13
14
class RecordMapper
15
{
16
    /**
17
     * Related ODM model.
18
     *
19
     * @var string
20
     */
21
    private $class = '';
22
23
    /**
24
     * @var ORMInterface
25
     */
26
    protected $orm = null;
27
28
    /**
29
     * @param string       $class
30
     * @param ORMInterface $orm
31
     */
32
    public function __construct($class, ORMInterface $orm)
33
    {
34
        $this->class = $class;
35
        $this->orm = $orm;
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function getTable()
42
    {
43
        return $this->orm->schema($this->class, ORMInterface::M_TABLE);
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getDatabase()
50
    {
51
        return $this->orm->schema($this->class, ORMInterface::M_DB);
52
    }
53
54
    /**
55
     * Insert new row into dbal table.
56
     *
57
     * @param array $data
58
     * @return bool|\MongoId|null Null if failure.
59
     */
60
    public function insert(array $data)
0 ignored issues
show
Unused Code introduced by
The parameter $data is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
61
    {
62
        //todo: implement
63
    }
64
65
    /**
66
     * Update row in related table.
67
     *
68
     * @param array $criteria Search criteria (usually id => value)
69
     * @param array $updates  DBAL updates, must be provided in a form of column => value and can
70
     *                        include expressions.
71
     * @return bool
72
     */
73
    public function update(array $criteria, array $updates)
0 ignored issues
show
Unused Code introduced by
The parameter $criteria is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $updates is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
74
    {
75
        //todo: implement
76
    }
77
78
    /**
79
     * Delete document from related collection.
80
     *
81
     * @param array $criteria Search criteria (usually id => value)
82
     * @return array|bool
83
     */
84
    public function delete(array $criteria)
0 ignored issues
show
Unused Code introduced by
The parameter $criteria is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
85
    {
86
        //todo: implement
87
    }
88
89
    /**
90
     * @return Table
91
     */
92
    private function dbalTable()
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
93
    {
94
        return $this->dbalDatabase()->table($this->getTable());
95
    }
96
97
    /**
98
     * @return Database
99
     */
100
    private function dbalDatabase()
101
    {
102
        return $this->orm->database($this->getDatabase());
103
    }
104
}