Passed
Push — develop ( 60641a...1612eb )
by Csaba
58s
created

RestObject   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 26
c 0
b 0
f 0
wmc 4
lcom 1
cbo 5
ccs 0
cts 11
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A find() 0 9 2
A validateUniqueFields() 0 4 1
A query() 0 5 1
1
<?php
2
namespace Fathomminds\Rest\Database\MongoDB;
3
4
use Fathomminds\Rest\Objects\RestObject as CoreRestObject;
5
use MongoDB\Client;
6
7
/**
8
 *
9
 * @method Client getClient()
10
 *
11
 */
12
13
14
class RestObject extends CoreRestObject
15
{
16
    protected $primaryKey = '_id';
17
    protected $databaseClass = Database::class;
18
19
    public function find($client = null)
20
    {
21
        if ($client === null) {
22
            $client = $this->getClient();
23
        }
24
        return (new Finder($client))
25
            ->database($this->getDatabaseName())
26
            ->from($this->getResourceName());
27
    }
28
29
    public function validateUniqueFields()
30
    {
31
        //
32
    }
33
34
    public function query()
35
    {
36
        $query = $this->getClient()->selectDatabase($this->getDatabaseName())->selectCollection($this->resourceName);
37
        return $query;
38
    }
39
}
40