Completed
Pull Request — master (#15)
by Martin
61:47 queued 54:36
created

TwitalResource::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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
    public function __construct(TwitalLoader $loader, ResourceInterface $resource)
21
    {
22
        $this->loader = $loader;
23
        $this->resource = $resource;
24
    }
25
26
    public function getContent()
27
    {
28
        $source = $this->resource->getContent();
29
30
        if ($adapter = $this->loader->getSourceAdapter(strval($this->resource))) {
31
            $source = $this->loader->getTwital()->compile($adapter, $source);
32
        }
33
34
        return $source;
35
    }
36
37
    public function isFresh($timestamp)
38
    {
39
        return $this->resource->isFresh($timestamp);
40
    }
41
42
    public function __toString()
43
    {
44
        return strval($this->resource);
45
    }
46
}
47