Passed
Push — master ( 9afe80...f5220c )
by Gabriel
03:51
created

assets.php ➔ assets_manager()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 6
nop 0
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
1
<?php
2
3
use ByTIC\Container\Container;
0 ignored issues
show
Bug introduced by
The type ByTIC\Container\Container was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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
    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
    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
    $container = function_exists('app') ? app() : Container::getInstance();
36
    if (!$container) {
37
        /** @noinspection PhpUnhandledExceptionInspection */
38
        throw new Exception("No container was found for assets_manager function");
39
    }
40
41
    $manager = $container->get('assets.manager');
42
    if (!$manager) {
43
        /** @noinspection PhpUnhandledExceptionInspection */
44
        throw new Exception("No Assets Manager was found in the container");
45
    }
46
47
    return $manager;
48
}
49