SearchResult   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 86.67%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 65
ccs 13
cts 15
cp 0.8667
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A setMetadata() 0 8 2
A getMatchType() 0 4 1
A getMetadata() 0 4 1
1
<?php
2
namespace Dropbox\Models;
3
4
class SearchResult extends BaseModel
5
{
6
7
    /**
8
     * Indicates what type of match was found for the result
9
     *
10
     * @var string
11
     */
12
    protected $matchType = null;
13
14
    /**
15
     * File\Folder Metadata
16
     *
17
     * @var \Dropbox\Models\FileMetadata|\Dropbox\Models\FolderMetadata
18
     */
19
    protected $metadata;
20
21
22
    /**
23
     * Create a new SearchResult instance
24
     *
25
     * @param array $data
26
     */
27 3
    public function __construct(array $data)
28
    {
29 3
        parent::__construct($data);
30 3
        $matchType = $this->getDataProperty('match_type');
31 3
        $this->matchType = isset($matchType['.tag']) ? $matchType['.tag'] : null;
32 3
        $this->setMetadata();
33 3
    }
34
35
    /**
36
     * Set Metadata
37
     *
38
     * @return void
39
     */
40 3
    protected function setMetadata()
41
    {
42 3
        $metadata = $this->getDataProperty('metadata');
43
44 3
        if (is_array($metadata)) {
45 3
            $this->metadata = ModelFactory::make($metadata);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Dropbox\Models\ModelFactory::make($metadata) of type object<Dropbox\Models\ModelInterface> is incompatible with the declared type object<Dropbox\Models\Fi...\Models\FolderMetadata> of property $metadata.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
46
        }
47 3
    }
48
49
    /**
50
     * Indicates what type of match was found for the result
51
     *
52
     * @return bool
53
     */
54
    public function getMatchType()
55
    {
56
        return $this->matchType;
57
    }
58
59
    /**
60
     * Get the Search Result Metadata
61
     *
62
     * @return \Dropbox\Models\FileMetadata|\Dropbox\Models\FolderMetadata
63
     */
64 3
    public function getMetadata()
65
    {
66 3
        return $this->metadata;
67
    }
68
}
69