CFilms::program()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 11
cts 11
cp 1
rs 9.2
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 0
crap 2
1
<?php
2
3
namespace rolb\CFilm;
4
5
class CFilms
6
{
7
    private $apikey;
8
    private $date;
9
10
11
12
    /**
13
     * CFilms constructor.
14
     * @param $apikey
15
     * @param $date
16
     */
17 4
    public function __construct($apikey, $date)
18
    {
19 4
        $this->apikey = $apikey;
20 4
        $this->date = $date;
21 4
    }
22
23
24
    /**
25
     * Renders the html
26
     */
27 1
    public function program()
28
    {
29 1
        $data = $this->getProg();
30
31 1
        $html = '<div class="date"> Stockholms Filmfestival Programme ' . $this->date . '<br></div>';
32
33 1
        foreach($data as $value) {
34
35 1
            $filmid = $value["filmId"];
36
37 1
            $html .= '<br><div class="ftime">' . substr(htmlentities($value["eventTime"]), 0, -3) . '</div>';
38
39 1
            $html .= '<div class="fname"><a href="sthlmfilms?film=' . $filmid . '">' . htmlentities($value["eventName_en"]) . '</a></div>';
40
41 1
            $html .= '<div class="fvenue">Venue: ' . htmlentities($value["venueName"]) . '</div>';
42
43 1
            $html .= '<br>';
44
45 1
        }
46
47 1
        return $html;
48
    }
49
50 1
    public function filmInfo($filmid)
51
    {
52 1
        $filmdata = $this->getFilm($filmid);
53
54 1
        $html = '';
55 1
        $html .= '<br><div class="ftitle">' . htmlentities($filmdata["filmName"]) . '</div>';
56 1
        $html .= '<br><div class="fdir"> Director: ' . htmlentities($filmdata["filmDirector"]) . '</div>';
57 1
        $html .= '<br><div class="flength">' . htmlentities($filmdata["filmLength"]) . ' minutes </div>';
58 1
        $html .= '<br><div class="finfo">' . htmlentities($filmdata["filmDescription_en"]) . '</div>';
59 1
        $html .= '<br><div class="flink"> <iframe width="420" height="315"src="https://www.youtube.com/embed/' . htmlentities($filmdata["filmYoutubeId"]) . '"></iframe></div>';
60
61 1
        return $html;
62
    }
63
64 2 View Code Duplication
    private function getProg()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
65
    {
66
67 2
        $result = file_get_contents("http://api.stockholmfilmfestival.se/v1/events/date_list/format/json/date/"
68 2
            . $this->date . "/API-Key/" . $this->apikey);
69
70 2
        return json_decode($result, true);
71
    }
72
73
74 2 View Code Duplication
    private function getFilm($filmid)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
75
    {
76
77 2
        $result = file_get_contents("http://api.stockholmfilmfestival.se/v1/films/film/film_id/"
78 2
            . $filmid . "/API-Key/" . $this->apikey . "/format/json/");
79
80 2
        return json_decode($result, true);
81
    }
82
83
}