GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( f80a23...a34f50 )
by Luis Ramón
03:18
created

UserRepository::createNewUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
/*
3
  ÁTICA - Aplicación web para la gestión documental de centros educativos
4
5
  Copyright (C) 2015-2016: Luis Ramón López López
6
7
  This program is free software: you can redistribute it and/or modify
8
  it under the terms of the GNU Affero General Public License as published by
9
  the Free Software Foundation, either version 3 of the License, or
10
  (at your option) any later version.
11
12
  This program is distributed in the hope that it will be useful,
13
  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  GNU Affero General Public License for more details.
16
17
  You should have received a copy of the GNU Affero General Public License
18
  along with this program.  If not, see [http://www.gnu.org/licenses/].
19
*/
20
21
namespace AppBundle\Entity;
22
23
use Doctrine\ORM\EntityRepository;
24
use Symfony\Component\Security\Core\User\UserInterface;
25
use Symfony\Component\Security\Core\User\UserProviderInterface;
26
27
class UserRepository extends EntityRepository implements UserProviderInterface
28
{
29
    public function loadUserByUsername($username) {
30
31
        if (!$username) {
32
            return null;
33
        }
34
        return $this->getEntityManager()
35
            ->createQuery('SELECT u FROM AppBundle:User u JOIN u.person p
36
                           WHERE u.username = :username
37
                           OR p.email = :username')
38
            ->setParameters([
39
                'username' => $username
40
            ])
41
            ->getOneOrNullResult();
42
    }
43
44
    public function refreshUser(UserInterface $user) {
45
        return $this->loadUserByUsername($user->getUsername());
46
    }
47
48
    public function supportsClass($class) {
49
        return $class === 'AppBundle\Entity\User';
50
    }
51
52
    /**
53
     * Crea un nuevo usuario y su persona asociada
54
     *
55
     * @return User
56
     */
57
    public function createNewUser()
58
    {
59
        $user = new User();
60
        $person = new Person();
61
        $person->setDisplayName('');
62
        $user->setPerson($person);
63
64
        $this->getEntityManager()->persist($user->getPerson());
65
        $this->getEntityManager()->persist($user);
66
67
        return $user;
68
    }
69
}
70