aboutsummaryrefslogtreecommitdiff
path: root/bridges/FirefoxReleaseNotesBridge.php
blob: c74c9d51b00cc4b96d47416410b78148389525f3 (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
44
45
46
47
<?php

class FirefoxReleaseNotesBridge extends BridgeAbstract
{
    const NAME = 'Firefox Release Notes';
    const URI = 'https://www.mozilla.org/en-US/firefox/';
    const DESCRIPTION = 'Retrieve the latest Firefox release notes.';
    const MAINTAINER = 'tillcash';
    const PARAMETERS = [
        [
            'platform' => [
                'name' => 'Platform',
                'type' => 'list',
                'values' => [
                    'Desktop' => '',
                    'Beta' => 'beta',
                    'Nightly' => 'nightly',
                    'Android' => 'android',
                    'iOS' => 'ios',
                ]
            ]
        ]
    ];

    public function getName()
    {
        $platform = $this->getKey('platform');
        return sprintf('Firefox %s Release Notes', $platform ?? '');
    }

    public function collectData()
    {
        $platform = $this->getKey('platform');
        $url = self::URI . $this->getInput('platform') . '/notes/';
        $dom = getSimpleHTMLDOM($url);

        $version = $dom->find('.c-release-version', 0)->innertext;

        $this->items[] = [
            'content' => $dom->find('.c-release-notes', 0)->innertext,
            'timestamp' => $dom->find('.c-release-date', 0)->innertext,
            'title' => sprintf('Firefox %s %s Release Note', $platform, $version),
            'uri' => $url,
            'uid' => $platform . $version,
        ];
    }
}