TwitalResource   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 76.92%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 34
ccs 10
cts 13
cp 0.7692
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
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