RecommendedSites   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A forLanguage() 0 11 2
1
<?php
2
/**
3
 * ownCloud - News
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Alessandro Cosentino <[email protected]>
9
 * @author Bernhard Posselt <[email protected]>
10
 * @copyright Alessandro Cosentino 2012
11
 * @copyright Bernhard Posselt 2012, 2014
12
 */
13
14
namespace OCA\News\Explore;
15
16
class RecommendedSites {
17
18
    private $directory;
19
20
    /**
21
     * @param string $exploreDir the absolute path to where the recommendation
22
     * config files lie without a trailing slash
23
     */
24
    public function __construct($exploreDir) {
25
        $this->directory = $exploreDir;
26
    }
27
28
29
    public function forLanguage($languageCode) {
30
        $file = $this->directory . '/feeds.' . $languageCode . '.json';
31
32
        if (file_exists($file)) {
33
            return json_decode(file_get_contents($file), true);
34
        } else {
35
            $msg = 'No recommended sites found for language code ' .
36
                $languageCode;
37
            throw new RecommendedSiteNotFoundException($msg);
38
        }
39
    }
40
41
42
}
43