Completed
Push — master ( 586b8e...cb0e4b )
by De Cramer
04:39 queued 53s
created

PlayerRepository::save()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 9
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 1
crap 12
1
<?php
2
3
namespace eXpansion\Framework\PlayersBundle\Repository;
4
5
use eXpansion\Framework\PlayersBundle\Entity\Player;
6
7
/**
8
 * PlayerRepository
9
 *
10
 * This class was generated by the Doctrine ORM. Add your own custom
11
 * repository methods below.
12
 */
13
class PlayerRepository extends \Doctrine\ORM\EntityRepository
14
{
15
    /**
16
     * @param string $login Login of the player to laod.
17
     *
18
     * @return Player|null
19
     */
20
    public function findByLogin($login)
21
    {
22
        $player = $this->findOneBy(['login' => $login]);
23
        return $player;
24
    }
25
26
    /**
27
     * Save player data in database.
28
     *
29
     * @param Player[] $players
30
     */
31
    public function save(array $players)
32
    {
33
        if (empty($players)) {
34
            return;
35
        }
36
37
        foreach ($players as $player) {
38
            var_dump($player->getId());
0 ignored issues
show
Security Debugging Code introduced by
var_dump($player->getId()); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
39
            $player = $this->getEntityManager()->merge($player);
40
            $this->getEntityManager()->persist($player);
41
        }
42
43
        $this->getEntityManager()->flush();
44
    }
45
}
46