Passed
Push — master ( 4f7cfa...de2995 )
by Gabriel
03:24
created

HasEntrypointLookup::getEntrypointLookup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace ByTIC\Assets\AssetsManager;
4
5
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupInterface;
6
7
/**
8
 * Trait HasEntrypointLookup
9
 * @package ByTIC\Assets\AssetsManager
10
 */
11
trait HasEntrypointLookup
12
{
13 1
    protected function getEntrypointLookup(string $entrypointName): EntrypointLookupInterface
14
    {
15 1
        return $this->getContainer()->get('assets.entrypoint_lookup')->getEntrypointLookup($entrypointName);
0 ignored issues
show
Bug introduced by
It seems like getContainer() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

15
        return $this->/** @scrutinizer ignore-call */ getContainer()->get('assets.entrypoint_lookup')->getEntrypointLookup($entrypointName);
Loading history...
16
    }
17
18
    /**
19
     * @param string $entrypointName
20
     * @return bool|false
21
     */
22
    public function hasEntrypoint(string $entrypointName)
23
    {
24
        try {
25
            $this->getEntrypointLookup($entrypointName);
26
        } catch (\Exception $e) {
27
            return false;
28
        }
29
        return true;
30
    }
31
32 1
    public function getWebpackJsFiles(string $entryName, string $entrypointName = '_default'): array
33
    {
34 1
        return $this->getEntrypointLookup($entrypointName)
35 1
            ->getJavaScriptFiles($entryName);
36
    }
37
38 1
    public function getWebpackCssFiles(string $entryName, string $entrypointName = '_default'): array
39
    {
40 1
        return $this->getEntrypointLookup($entrypointName)
41 1
            ->getCssFiles($entryName);
42
    }
43
}
44