Completed
Push — travis ( f73ca9 )
by Asmir
03:03
created

TwitalResource   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 34
ccs 10
cts 14
cp 0.7143
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getContent() 0 10 2
A isFresh() 0 4 1
A __toString() 0 4 1
1
<?php
2
namespace Goetas\TwitalBundle\Assetic\Resource;
3
4
use Assetic\Factory\Resource\ResourceInterface;
5
use Goetas\Twital\TwitalLoader;
6
7
/**
8
 *
9
 * @author Asmir Mustafic <[email protected]>
10
 *
11
 */
12
class TwitalResource implements ResourceInterface
13
{
14
15
    private $loader;
16
17
    private $resource;
18
19 1
    public function __construct(TwitalLoader $loader, ResourceInterface $resource)
20
    {
21 1
        $this->loader = $loader;
22 1
        $this->resource = $resource;
23 1
    }
24
25 1
    public function getContent()
26
    {
27 1
        $source = $this->resource->getContent();
28
29 1
        if ($adapter = $this->loader->getSourceAdapter(strval($this->resource))) {
30
            $source = $this->loader->getTwital()->compile($adapter, $source);
31
        }
32
33 1
        return $source;
34
    }
35
36
    public function isFresh($timestamp)
37
    {
38
        return $this->resource->isFresh($timestamp);
39
    }
40
41 1
    public function __toString()
42
    {
43 1
        return strval($this->resource);
44
    }
45
}
46