Completed
Branch GDPR/user-data-export (1838dd)
by
unknown
53:17 queued 40:13
created

StylesheetAsset   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 60
c 0
b 0
f 0
rs 10
wmc 5
lcom 1
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A media() 0 4 1
A setMedia() 0 11 2
A enqueueAsset() 0 4 1
1
<?php
2
3
namespace EventEspresso\core\domain\values\assets;
4
5
use EventEspresso\core\domain\DomainInterface;
6
use EventEspresso\core\exceptions\InvalidDataTypeException;
7
8
/**
9
 * Class StylesheetAsset
10
 * Details for a Cascading Stylesheet asset
11
 *
12
 * @package EventEspresso\core\domain\values\assets
13
 * @author  Brent Christensen
14
 * @since   $VID:$
15
 */
16
class StylesheetAsset extends BrowserAsset
17
{
18
19
    /**
20
     * @var string $media
21
     */
22
    private $media;
23
24
25
    /**
26
     * CssFile constructor.
27
     *
28
     * @param                 $handle
29
     * @param string          $source
30
     * @param array           $dependencies
31
     * @param DomainInterface $domain
32
     * @param                 $media
33
     * @throws InvalidDataTypeException
34
     */
35
    public function __construct($handle, $source, array $dependencies, DomainInterface $domain, $media = 'all')
36
    {
37
        parent::__construct(Asset::TYPE_CSS, $handle, $source, $dependencies, $domain);
38
        $this->setMedia($media);
39
    }
40
41
42
    /**
43
     * @return string
44
     */
45
    public function media()
46
    {
47
        return $this->media;
48
    }
49
50
51
    /**
52
     * @param string $media
53
     * @throws InvalidDataTypeException
54
     */
55
    private function setMedia($media)
56
    {
57
        if (! is_string($media)) {
58
            throw new InvalidDataTypeException(
59
                '$media',
60
                $media,
61
                'string'
62
            );
63
        }
64
        $this->media = $media;
65
    }
66
67
68
    /**
69
     * @since $VID:$
70
     */
71
    public function enqueueAsset()
72
    {
73
        wp_enqueue_style($this->handle());
74
    }
75
}
76