Completed
Push — 4.0 ( 6f2c9f...73108a )
by David
17s queued 11s
created

createRootUrlWebLibrary()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
4
namespace Mouf\Html\Utils\WebLibraryManager;
5
6
use Mouf\Html\HtmlElement\HtmlFromFile;
7
use Mouf\Html\HtmlElement\Scopable;
8
use Mouf\Html\Renderer\RendererInterface;
9
use Psr\Container\ContainerInterface;
10
use TheCodingMachine\Funky\Annotations\Factory;
11
use TheCodingMachine\Funky\Annotations\Tag;
12
use TheCodingMachine\Funky\ServiceProvider;
13
14
class WebLibraryManagerServiceProvider extends ServiceProvider implements Scopable
15
{
16
    /**
17
     * @Factory()
18
     */
19
    public static function createWebLibraryManager(ContainerInterface $container, RendererInterface $renderer): WebLibraryManager
20
    {
21
        return new WebLibraryManager($renderer, \iterator_to_array($container->get('webLibraries')));
22
    }
23
24
    /**
25
     * @Factory(name="webLibraries")
26
     */
27
    public static function createWebLibraries(): \SplPriorityQueue
28
    {
29
        return new \SplPriorityQueue();
30
    }
31
32
    private $rootUrl;
33
34
    /**
35
     * @Factory(name="rootUrlInlineWebLibrary", tags={@Tag(name="webLibraries", priority=0.0)})
36
     */
37
    public static function createRootUrlWebLibrary(ContainerInterface $container): InlineWebLibrary
38
    {
39
        $scope = new self();
40
        $scope->rootUrl = $container->get('ROOT_URL');
41
42
        $webLibrarayManagerDir = \ComposerLocator::getPath('mouf/html.utils.weblibrarymanager');
0 ignored issues
show
Bug introduced by
The method getPath() does not seem to exist on object<ComposerLocator>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43
        $htmlFromFile = new HtmlFromFile($webLibrarayManagerDir.'/javascript/rootUrl.php', $scope);
44
        return new InlineWebLibrary($htmlFromFile);
45
    }
46
47
    /**
48
     * Loads the file.
49
     *
50
     * @param string $file
51
     */
52
    public function loadFile($file)
53
    {
54
        require $file;
55
    }
56
}
57