Completed
Pull Request — master (#132)
by
unknown
06:43 queued 04:56
created

ResourceTeleporter::teleport()   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 2
1
<?php
2
/*
3
 * This file is part of Zippy.
4
 *
5
 * (c) Alchemy <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace Alchemy\Zippy\Resource;
11
12
use Alchemy\Zippy\Resource\Resource as ZippyResource;
13
14
class ResourceTeleporter
15
{
16
    private $container;
17
18
    /**
19
     * Constructor
20
     *
21
     * @param TeleporterContainer $container
22
     */
23
    public function __construct(TeleporterContainer $container)
24
    {
25
        $this->container = $container;
26
    }
27
28
    /**
29
     * Teleports a resource to its target in the context
30
     *
31
     * @param string        $context
32
     * @param ZippyResource $resource
33
     *
34
     * @return ResourceTeleporter
35
     */
36
    public function teleport($context, ZippyResource $resource)
37
    {
38
        $this
39
            ->container
40
            ->fromResource($resource)
41
            ->teleport($resource, $context);
42
43
        return $this;
44
    }
45
46
    /**
47
     * Creates the ResourceTeleporter with the default TeleporterContainer
48
     *
49
     * @return ResourceTeleporter
50
     */
51
    public static function create()
52
    {
53
        return new static(TeleporterContainer::load());
54
    }
55
}
56