Failed Conditions
Push — master ( 6744b4...2b8acb )
by Marco
60:45 queued 60:36
created

Doctrine/Tests/Models/DDC3579/DDC3579User.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Doctrine\Tests\Models\DDC3579;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
7
/**
8
 * @MappedSuperclass
9
 */
10
class DDC3579User
11
{
12
13
    /**
14
     * @Id
15
     * @GeneratedValue
16
     * @Column(type="integer", name="user_id", length=150)
17
     */
18
    protected $id;
19
20
    /**
21
     * @Column(name="user_name", nullable=true, unique=false, length=250)
22
     */
23
    protected $name;
24
25
    /**
26
     * @var ArrayCollection
27
     *
28
     * @ManyToMany(targetEntity="DDC3579Group")
29
     */
30
    protected $groups;
31
32
    /**
33
     * @param string $name
34
     */
35
    public function __construct($name = null)
36
    {
37
        $this->name     = $name;
38
        $this->groups   = new ArrayCollection;
39
    }
40
41
    /**
42
     * @return integer
43
     */
44
    public function getId()
45
    {
46
        return $this->id;
47
    }
48
49
    /**
50
     * @return string
51
     */
52
    public function getName()
53
    {
54
        return $this->name;
55
    }
56
57
    /**
58
     * @param string $name
59
     */
60
    public function setName($name)
61
    {
62
        $this->name = $name;
63
    }
64
65
    /**
66
     * @param DDC3579Group $group
67
     */
68
    public function addGroup(DDC3579Group $group)
69
    {
70
        $this->groups->add($group);
71
        $group->addUser($this);
0 ignored issues
show
The method addUser() does not seem to exist on object<Doctrine\Tests\Mo...s\DDC3579\DDC3579Group>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
72
    }
73
74
    /**
75
     * @return ArrayCollection
76
     */
77
    public function getGroups()
78
    {
79
        return $this->groups;
80
    }
81
82
    public static function loadMetadata($metadata)
83
    {
84
        $metadata->mapField(
85
            [
86
           'id'         => true,
87
           'fieldName'  => 'id',
88
           'type'       => 'integer',
89
           'columnName' => 'user_id',
90
           'length'     => 150,
91
            ]
92
        );
93
94
        $metadata->mapField(
95
            [
96
            'fieldName' => 'name',
97
            'type'      => 'string',
98
            'columnName'=> 'user_name',
99
            'nullable'  => true,
100
            'unique'    => false,
101
            'length'    => 250,
102
            ]
103
        );
104
105
        $metadata->mapManyToMany(
106
            [
107
           'fieldName'      => 'groups',
108
           'targetEntity'   => 'DDC3579Group'
109
            ]
110
        );
111
112
        $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO);
113
    }
114
}
115