aboutsummaryrefslogtreecommitdiff
path: root/bridges/N26Bridge.php
blob: 8865600d40637b693415aae17de94ff085257f97 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

class N26Bridge extends BridgeAbstract
{
    const MAINTAINER = 'quentinus95';
    const NAME = 'N26 Blog';
    const URI = 'https://n26.com';
    const CACHE_TIMEOUT = 1800;
    const DESCRIPTION = 'Returns recent blog posts from N26.';

    public function collectData()
    {
        $limit = 5;
        $url = 'https://n26.com/en-eu/blog/all';
        $html = getSimpleHTMLDOM($url);

        $articles = $html->find('div[class="bl bm"]');

        foreach ($articles as $article) {
            $item = [];

            $itemUrl = self::URI . $article->find('a', 1)->href;
            $item['uri'] = $itemUrl;

            $item['title'] = $article->find('a', 1)->plaintext;

            $fullArticle = getSimpleHTMLDOM($item['uri']);

            $createdAt = $fullArticle->find('time', 0);
            $item['timestamp'] = strtotime($createdAt->plaintext);

            $this->items[] = $item;
            if (count($this->items) >= $limit) {
                break;
            }
        }
    }

    public function getIcon()
    {
        return 'https://n26.com/favicon.ico';
    }
}