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