| Total Complexity | 8 |
| Total Lines | 77 |
| Duplicated Lines | 0 % |
| Coverage | 61.9% |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 12 | class Asset |
||
| 13 | { |
||
| 14 | use Asset\Traits\CanRenderTrait; |
||
| 15 | use Asset\Traits\HasContentTrait; |
||
| 16 | |||
| 17 | const TYPE_STYLES = 'STYLES'; |
||
| 18 | const TYPE_SCRIPTS = 'SCRIPTS'; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $type; |
||
| 24 | |||
| 25 | protected $source = false; |
||
| 26 | protected $attribs = []; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Asset constructor. |
||
| 30 | * @param string $source |
||
| 31 | * @param string $type |
||
| 32 | */ |
||
| 33 | 9 | public function __construct(string $source = '', $type = '') |
|
| 34 | { |
||
| 35 | 9 | $this->source = AssetSource::check($source, $type); |
|
| 36 | 9 | $this->type = $type; |
|
| 37 | 9 | $this->attribs = AssetAttributes::defaultFor($type); |
|
| 38 | 9 | } |
|
| 39 | |||
| 40 | /** |
||
| 41 | * @return string |
||
| 42 | */ |
||
| 43 | 4 | public function getSource(): string |
|
| 44 | { |
||
| 45 | 4 | if ($this->source instanceof \Closure) { |
|
|
|
|||
| 46 | 4 | $this->source = ($this->source)(); |
|
| 47 | } |
||
| 48 | 4 | return $this->source; |
|
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @param string $source |
||
| 53 | */ |
||
| 54 | public function setSource(string $source): void |
||
| 55 | { |
||
| 56 | $this->source = $source; |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @return string |
||
| 61 | */ |
||
| 62 | 4 | public function getType(): string |
|
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @param string $type |
||
| 69 | */ |
||
| 70 | public function setType(string $type): void |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @return array |
||
| 77 | */ |
||
| 78 | 4 | public function getAttribs(): array |
|
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @param array $attribs |
||
| 85 | */ |
||
| 86 | public function setAttribs(array $attribs): void |
||
| 91 |