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

RestObject::find()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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