Completed
Push — master ( 65f484...cb55bb )
by Asmir
07:37 queued 02:12
created

TwitalResource::getContent()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 10
ccs 4
cts 5
cp 0.8
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 2.032
1
<?php
2
3
namespace Goetas\TwitalBundle\Assetic\Resource;
4
5
use Assetic\Factory\Resource\ResourceInterface;
6
use Goetas\Twital\TwitalLoader;
7
8
/**
9
 *
10
 * @author Asmir Mustafic <[email protected]>
11
 *
12
 */
13
class TwitalResource implements ResourceInterface
14
{
15
16
    private $loader;
17
18
    private $resource;
19
20 1
    public function __construct(TwitalLoader $loader, ResourceInterface $resource)
21
    {
22 1
        $this->loader = $loader;
23 1
        $this->resource = $resource;
24 1
    }
25
26 1
    public function getContent()
27
    {
28 1
        $source = $this->resource->getContent();
29
30 1
        if ($adapter = $this->loader->getSourceAdapter(strval($this->resource))) {
31
            $source = $this->loader->getTwital()->compile($adapter, $source);
32
        }
33
34 1
        return $source;
35
    }
36
37
    public function isFresh($timestamp)
38
    {
39
        return $this->resource->isFresh($timestamp);
40
    }
41
42 1
    public function __toString()
43
    {
44 1
        return strval($this->resource);
45
    }
46
}
47