Code Duplication    Length = 19-22 lines in 2 locations

src/Server/Transformer.php 1 location

@@ 142-163 (lines=22) @@
139
     *
140
     * @return array
141
     */
142
    public function transformNews($news)
143
    {
144
        $articles = [];
145
146
        if (!is_array($news)) {
147
            $news = [$news];
148
        }
149
150
        foreach ($news as $item) {
151
            $articles[] = [
152
                'Title'       => $item->get('title'),
153
                'Description' => $item->get('description'),
154
                'Url'         => $item->get('url'),
155
                'PicUrl'      => $item->get('pic_url'),
156
            ];
157
        }
158
159
        return [
160
            'ArticleCount' => count($articles),
161
            'Articles'     => $articles,
162
        ];
163
    }
164
165
    public function transformDeviceText(AbstractMessage $message)
166
    {

src/Staff/Transformer.php 1 location

@@ 125-143 (lines=19) @@
122
     *
123
     * @return array
124
     */
125
    public function transformNews($news)
126
    {
127
        $articles = [];
128
129
        if (!is_array($news)) {
130
            $news = [$news];
131
        }
132
133
        foreach ($news as $item) {
134
            $articles[] = [
135
                'title'       => $item->get('title'),
136
                'description' => $item->get('description'),
137
                'url'         => $item->get('url'),
138
                'picurl'      => $item->get('pic_url'),
139
            ];
140
        }
141
142
        return ['msgtype' => 'news', 'news' => ['articles' => $articles]];
143
    }
144
145
    /**
146
     * Transform material message.