Completed
Push — master ( 883ec5...9a51c3 )
by Wouter
02:47
created

InMemoryUserRepository::supportsClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace SumoCoders\FrameworkMultiUserBundle\User;
4
5
/**
6
 * Class InMemoryUserRepository
7
 */
8
class InMemoryUserRepository implements UserRepository
9
{
10
    /** @var array */
11
    private $user = [];
0 ignored issues
show
Unused Code introduced by
The property $user is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
12
13
    public function __construct()
14
    {
15
        $this->users[] = new User(
0 ignored issues
show
Bug introduced by
The property users 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...
16
            'wouter',
17
            'test',
18
            'Wouter Sioen'
19
        );
20
    }
21
22
    /**
23
     * {@inheritDoc}
24
     */
25
    public function findByUsername($username)
26
    {
27
        foreach ($this->users as $user) {
28
            if ($user->getUsername() === $username) {
29
                return $user;
30
            }
31
        }
32
    }
33
34
    /**
35
     * {@inheritDoc}
36
     */
37
    public function supportsClass($class)
38
    {
39
        return $class === User::class;
40
    }
41
}
42