Code Duplication    Length = 13-13 lines in 2 locations

src/Service/Note/GetOne.php 1 location

@@ 20-32 (lines=13) @@
17
        return $note;
18
    }
19
20
    public function getOneFromCache(int $noteId)
21
    {
22
        $redisKey = sprintf(self::REDIS_KEY, $noteId);
23
        $key = $this->redisService->generateKey($redisKey);
24
        if ($this->redisService->exists($key)) {
25
            $note = $this->redisService->get($key);
26
        } else {
27
            $note = $this->getOneFromDb($noteId);
28
            $this->redisService->setex($key, $note);
29
        }
30
31
        return $note;
32
    }
33
}
34

src/Service/TaskService.php 1 location

@@ 55-67 (lines=13) @@
52
        return $task;
53
    }
54
55
    public function getTaskFromCache(int $taskId, int $userId)
56
    {
57
        $redisKey = sprintf(self::REDIS_KEY, $taskId, $userId);
58
        $key = $this->redisService->generateKey($redisKey);
59
        if ($this->redisService->exists($key)) {
60
            $task = $this->redisService->get($key);
61
        } else {
62
            $task = $this->getTaskFromDb($taskId, $userId);
63
            $this->redisService->setex($key, $task);
64
        }
65
66
        return $task;
67
    }
68
69
    public function search($tasksName, int $userId, $status): array
70
    {