Code Duplication    Length = 19-20 lines in 2 locations

src/Resources/Messages.php 2 locations

@@ 64-83 (lines=20) @@
61
     * @throws \RuntimeException
62
     * @throws \Throwable
63
     */
64
    public function allBeforeId(string $roomId, string $beforeId = null, string $query = null)
65
    {
66
        $limit = 100;
67
68
        do {
69
            $route = $this->routeForMessagesIterator($roomId, $limit, $query);
70
71
            if ($beforeId !== null) {
72
                $route->with('beforeId', $beforeId);
73
            }
74
75
            $response = array_reverse($this->fetch($route));
76
77
            foreach ($response as $message) {
78
                $beforeId = (string)$message['id'];
79
                yield $message;
80
            }
81
82
        } while (count($response) >= $limit);
83
    }
84
85
    /**
86
     * @param string $roomId
@@ 117-135 (lines=19) @@
114
     * @throws \RuntimeException
115
     * @throws \Throwable
116
     */
117
    public function allAfterId(string $roomId, string $afterId = null, string $query = null)
118
    {
119
        $limit = 100;
120
121
        do {
122
            $route = $this->routeForMessagesIterator($roomId, $limit, $query);
123
124
            if ($afterId !== null) {
125
                $route->with('afterId', $afterId);
126
            }
127
128
            $response = (array)$this->fetch($route);
129
130
            foreach ($response as $message) {
131
                $afterId = (string)$message['id'];
132
                yield $message;
133
            }
134
        } while (count($response) >= $limit);
135
    }
136
137
    /**
138
     * There is also a way to retrieve a single message using its id.