Code Duplication    Length = 19-22 lines in 2 locations

src/Server/Transformer.php 1 location

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

src/Staff/Transformer.php 1 location

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