Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 3.0032 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
32 | 1 | public function insertView(Entity\Card $card, $ip) |
|
33 | { |
||
34 | 1 | $view = false; |
|
35 | 1 | if ($card->getId() == 0) { |
|
36 | return $view; |
||
37 | } |
||
38 | |||
39 | 1 | $isExists = $this->findOneBy(['card' => $card, 'ip' => ip2long($ip)]); |
|
40 | 1 | if (!$isExists) { |
|
41 | 1 | $view = new Entity\CardView(); |
|
42 | 1 | $view->setCard($card); |
|
43 | 1 | $view->setTimestamp(new \DateTime()); |
|
44 | 1 | $view->setIp($ip); |
|
45 | 1 | $em = $this->getEntityManager(); |
|
46 | 1 | $em->persist($view); |
|
47 | 1 | $em->flush(); |
|
48 | } |
||
49 | |||
50 | 1 | return $view; |
|
51 | } |
||
52 | } |
||
53 |