root / drupal7 / misc / typo3 / phar-stream-wrapper / src / Phar / Stub.php @ fbb66ca6
1 |
<?php
|
---|---|
2 |
namespace TYPO3\PharStreamWrapper\Phar; |
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 |
/**
|
15 |
* @internal Experimental implementation of Phar archive internals
|
16 |
*/
|
17 |
class Stub |
18 |
{ |
19 |
/**
|
20 |
* @param string $content
|
21 |
* @return self
|
22 |
*/
|
23 |
public static function fromContent($content) |
24 |
{ |
25 |
$target = new static(); |
26 |
$target->content = $content; |
27 |
|
28 |
if (
|
29 |
stripos($content, 'Phar::mapPhar(') !== false |
30 |
&& preg_match('#Phar\:\:mapPhar\(([^)]+)\)#', $content, $matches) |
31 |
) { |
32 |
// remove spaces, single & double quotes
|
33 |
// @todo `'my' . 'alias' . '.phar'` is not evaluated here
|
34 |
$target->mappedAlias = trim($matches[1], ' \'"'); |
35 |
} |
36 |
|
37 |
return $target; |
38 |
} |
39 |
|
40 |
/**
|
41 |
* @var string
|
42 |
*/
|
43 |
private $content; |
44 |
|
45 |
/**
|
46 |
* @var string
|
47 |
*/
|
48 |
private $mappedAlias = ''; |
49 |
|
50 |
/**
|
51 |
* @return string
|
52 |
*/
|
53 |
public function getContent() |
54 |
{ |
55 |
return $this->content; |
56 |
} |
57 |
|
58 |
/**
|
59 |
* @return string
|
60 |
*/
|
61 |
public function getMappedAlias() |
62 |
{ |
63 |
return $this->mappedAlias; |
64 |
} |
65 |
} |