Completed
Pull Request — master (#4)
by James Ekow Abaka
03:06 queued 36s
created

FeedHelper   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 49
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setItems() 0 4 1
A setUpdated() 0 4 1
A setDescription() 0 4 1
A help() 0 4 1
A __toString() 0 7 1
A setTitle() 0 4 1
A setUrl() 0 4 1
1
<?php
2
/*
3
 * Ntentan Framework
4
 * Copyright (c) 2008-2015 James Ekow Abaka Ainooson
5
 * 
6
 * Permission is hereby granted, free of charge, to any person obtaining
7
 * a copy of this software and associated documentation files (the
8
 * "Software"), to deal in the Software without restriction, including
9
 * without limitation the rights to use, copy, modify, merge, publish,
10
 * distribute, sublicense, and/or sell copies of the Software, and to
11
 * permit persons to whom the Software is furnished to do so, subject to
12
 * the following conditions:
13
 * 
14
 * The above copyright notice and this permission notice shall be
15
 * included in all copies or substantial portions of the Software.
16
 * 
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
24
 */
25
26
namespace ntentan\honam\engines\php\helpers;
27
28
use ntentan\honam\engines\php\Helper;
29
30
/**
31
 * The FeedHelper provides a generic way of generating feeds. The FeedHelper has
32
 * drivers which generate specific feed formats RSS and (Atom in a later release).
33
 */
34
class FeedHelper extends Helper
35
{
36
    private $items;
37
    private $properties = array();
38
    private $format = 'rss';
39
    
40 1
    public function help($items)
41
    {
42 1
        $this->items = $items;
43 1
        return $this;
44
    }
45
46 2
    public function setItems($items)
47
    {
48 2
        $this->items = $items;
49 2
        return $this;
50
    }
51
    
52 3
    public function setTitle($title)
53
    {
54 3
        $this->properties['title'] = $title;
55 3
        return $this;
56
    }
57
    
58 3
    public function setUrl($url)
59
    {
60 3
        $this->properties['url'] = $url;
61 3
        return $this;
62
    }
63
    
64 3
    public function setUpdated($updated)
65
    {
66 3
        $this->properties['updated'] = $updated;
67 3
        return $this;
68
    }
69
    
70 3
    public function setDescription($desccription)
71
    {
72 3
        $this->properties['description'] = $desccription;
73 3
        return $this;
74
    }
75
76 3
    public function __toString()
77
    {
78 3
        $generatorClassName = ucfirst($this->format) . "Feed";
79 3
        $generatorClass = __NAMESPACE__ . "\\feed\\generators\\$generatorClassName";
80 3
        $generator = new $generatorClass();
81 3
        $generator->setup($this->properties, $this->items);
82 3
        return $generator->generate();
83
    }
84
}
85