Passed
Push — master ( fcb909...cb681d )
by Robbie
02:26
created

SupportedAddonsLoader::resolveVersion()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace BringYourOwnIdeas\Maintenance\Util;
4
5
/**
6
 * Handles fetching supported addon details from addons.silverstripe.org
7
 */
8
class SupportedAddonsLoader extends ApiLoader
9
{
10
    /**
11
     * Return the list of supported addons as provided by addons.silverstripe.org
12
     *
13
     * @return array
14
     */
15
    public function getAddonNames()
16
    {
17
        $endpoint = 'addons.silverstripe.org/api/supported-addons';
18
        return $this->doRequest($endpoint, function ($responseBody) {
19
            return isset($responseBody['addons']) ? $responseBody['addons'] : [];
20
        });
21
    }
22
23
    protected function getCacheKey()
24
    {
25
        return 'addons';
26
    }
27
}
28