Code Duplication    Length = 19-22 lines in 3 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.

src/Broadcast/Transformer.php 1 location

@@ 140-159 (lines=20) @@
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
                'btntxt'      => $item->get('btntxt'),
155
            ];
156
        }
157
158
        return ['msgtype' => 'news', 'news' => ['articles' => $articles]];
159
    }
160
161
    /**
162
     * Transform articles message.