Code Duplication    Length = 11-14 lines in 2 locations

app/Console/Commands/GitterRoomSyncCommand.php 1 location

@@ 101-114 (lines=14) @@
98
    /**
99
     * @param GitterRoom $room
100
     */
101
    public function syncMessages(GitterRoom $room)
102
    {
103
        /** @var CircleProgress $circle */
104
        $this->output->writeln('Fetching...');
105
106
        $room->getMessages()
107
            // Fetch all messages
108
            ->fetch(function (GitterMessage $message, Controls $controls) {
109
                $this->messageRemember($message, $controls);
110
            })
111
            ->then(function () use ($room) {
112
                $this->syncLatestMessages($room);
113
            });
114
    }
115
116
    /**
117
     * @param GitterMessage $gitterMessage

app/Console/Commands/GitterRoomListenCommand.php 1 location

@@ 179-189 (lines=11) @@
176
            ->first();
177
178
        if ($lastMessage) {
179
            $loop->addTimer($timeout, function () use ($gitter, $lastMessage) {
180
                $gitter->getMessages($lastMessage->gitter_id, GitterRoom::MESSAGE_FETCH_ASC)
181
                    ->fetch(function (GitterMessage $message, Controls $controls) {
182
                        $this->onMessage($message);
183
                        $controls->next();
184
                    })
185
                    ->then(function () use ($gitter) {
186
                        $this->warn('Connection...');
187
                        $this->listen($gitter);
188
                    });
189
            });
190
        } else {
191
            $this->listen($gitter);
192
        }