Passed
Pull Request — master (#84)
by Csaba
02:32
created

RestObject::validateUniqueFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 1
nc 1
nop 0
crap 2
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