assets_render_link_files()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 3
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
c 1
b 0
f 1
1
<?php
2
3
use Nip\Container\Container;
4
5
/**
6
 * @param $entryName
7
 * @param null $packageName
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $packageName is correct as it would always require null to be passed?
Loading history...
8
 * @param null $entrypointName
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $entrypointName is correct as it would always require null to be passed?
Loading history...
9
 * @return string
10
 * @noinspection PhpDocMissingThrowsInspection
11
 */
12
function assets_render_scripts_files($entryName, string $packageName = null, string $entrypointName = '_default')
13
{
14 1
    return assets_manager()->renderWebpackScriptTags($entryName, $packageName, $entrypointName);
0 ignored issues
show
Bug introduced by
It seems like $packageName can also be of type string; however, parameter $packageName of ByTIC\Assets\AssetsManag...nderWebpackScriptTags() does only seem to accept null, maybe add an additional type check? ( Ignorable by Annotation )

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

14
    return assets_manager()->renderWebpackScriptTags($entryName, /** @scrutinizer ignore-type */ $packageName, $entrypointName);
Loading history...
15
}
16
17
/**
18
 * @param $entryName
19
 * @param string $packageName
20
 * @param string $entrypointName
21
 * @return string
22
 * @noinspection PhpDocMissingThrowsInspection
23
 */
24
function assets_render_link_files($entryName, string $packageName = null, string $entrypointName = '_default')
25
{
26 1
    return assets_manager()->renderWebpackLinkTags($entryName, $packageName, $entrypointName);
27
}
28
29
/**
30
 * @return \ByTIC\Assets\AssetsManager
31
 * @throws Exception
32
 */
33
function assets_manager()
34
{
35 3
    $container = function_exists('app') ? app() : Container::getInstance();
36 3
    if (!$container) {
37
        /** @noinspection PhpUnhandledExceptionInspection */
38
        throw new Exception("No container was found for assets_manager function");
39
    }
40
41 3
    $manager = $container->get('assets.manager');
42 3
    if (!$manager) {
43
        /** @noinspection PhpUnhandledExceptionInspection */
44
        throw new Exception("No Assets Manager was found in the container");
45
    }
46
47 3
    return $manager;
48
}
49