root / drupal7 / misc / typo3 / phar-stream-wrapper / src / Manager.php @ cd5c298a
1 |
<?php
|
---|---|
2 |
namespace TYPO3\PharStreamWrapper; |
3 |
|
4 |
/*
|
5 |
* This file is part of the TYPO3 project.
|
6 |
*
|
7 |
* It is free software; you can redistribute it and/or modify it under the terms
|
8 |
* of the MIT License (MIT). For the full copyright and license information,
|
9 |
* please read the LICENSE file that was distributed with this source code.
|
10 |
*
|
11 |
* The TYPO3 project - inspiring people to share!
|
12 |
*/
|
13 |
|
14 |
class Manager implements Assertable |
15 |
{ |
16 |
/**
|
17 |
* @var self
|
18 |
*/
|
19 |
private static $instance; |
20 |
|
21 |
/**
|
22 |
* @var Behavior
|
23 |
*/
|
24 |
private $behavior; |
25 |
|
26 |
/**
|
27 |
* @param Behavior $behaviour
|
28 |
* @return self
|
29 |
*/
|
30 |
public static function initialize(Behavior $behaviour) |
31 |
{ |
32 |
if (self::$instance === null) { |
33 |
self::$instance = new self($behaviour); |
34 |
return self::$instance; |
35 |
} |
36 |
throw new \LogicException( |
37 |
'Manager can only be initialized once',
|
38 |
1535189871
|
39 |
); |
40 |
} |
41 |
|
42 |
/**
|
43 |
* @return self
|
44 |
*/
|
45 |
public static function instance() |
46 |
{ |
47 |
if (self::$instance !== null) { |
48 |
return self::$instance; |
49 |
} |
50 |
throw new \LogicException( |
51 |
'Manager needs to be initialized first',
|
52 |
1535189872
|
53 |
); |
54 |
} |
55 |
|
56 |
/**
|
57 |
* @return bool
|
58 |
*/
|
59 |
public static function destroy() |
60 |
{ |
61 |
if (self::$instance === null) { |
62 |
return false; |
63 |
} |
64 |
self::$instance = null; |
65 |
return true; |
66 |
} |
67 |
|
68 |
/**
|
69 |
* @param Behavior $behaviour
|
70 |
*/
|
71 |
private function __construct(Behavior $behaviour) |
72 |
{ |
73 |
$this->behavior = $behaviour; |
74 |
} |
75 |
|
76 |
/**
|
77 |
* @param string $path
|
78 |
* @param string $command
|
79 |
* @return bool
|
80 |
*/
|
81 |
public function assert($path, $command) |
82 |
{ |
83 |
return $this->behavior->assert($path, $command); |
84 |
} |
85 |
} |