Completed
Push — travis ( f73ca9 )
by Asmir
03:03
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.1481

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 4
cts 6
cp 0.6667
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 2.1481
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