Article   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getId() 0 4 1
A getTitle() 0 4 1
A setTitle() 0 4 1
A getContent() 0 4 1
A setContent() 0 4 1
A getAuthor() 0 4 1
A setAuthor() 0 4 1
A getTags() 0 4 1
A addTags() 0 4 1
1
<?php
2
3
namespace Khepin\Fixture\Document;
4
5
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
6
use Doctrine\Common\Collections\ArrayCollection;
7
8
/**
9
 * @ODM\Document
10
 */
11
class Article
12
{
13
    /**
14
     * @ODM\Id
15
     */
16
    private $id;
17
18
    /**
19
     * @ODM\String
20
     */
21
    private $title;
22
23
    /**
24
     * @ODM\EmbedOne(targetDocument="Author")
25
     */
26
    private $author;
27
28
    /**
29
     * @ODM\EmbedMany(targetDocument="Tag")
30
     */
31
    private $tags;
32
33
    /**
34
     * @ODM\String
35
     * @var type
36
     */
37
    private $content;
38
39
    public function __construct()
40
    {
41
        $this->comments = new ArrayCollection;
0 ignored issues
show
Bug introduced by
The property comments does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
42
    }
43
44
    public function getId()
45
    {
46
        return $this->id;
47
    }
48
49
    public function getTitle()
50
    {
51
        return $this->title;
52
    }
53
54
    public function setTitle($title)
55
    {
56
        $this->title = $title;
57
    }
58
59
    public function getContent()
60
    {
61
        return $this->content;
62
    }
63
64
    public function setContent($content)
65
    {
66
        $this->content = $content;
67
    }
68
69
    public function getAuthor()
70
    {
71
        return $this->author;
72
    }
73
74
    public function setAuthor(Author $author)
75
    {
76
        $this->author = $author;
77
    }
78
79
    public function getTags()
80
    {
81
        return $this->tags;
82
    }
83
84
    public function addTags(Tag $tag)
85
    {
86
        $this->tags[] = $tag;
87
    }
88
}
89