Comparator
3 years ago
Exception
3 years ago
Iterator
3 years ago
Finder.php
4 years ago
Gitignore.php
4 years ago
Glob.php
4 years ago
SplFileInfo.php
4 years ago
index.php
3 years ago
SplFileInfo.php
40 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\Finder; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | class SplFileInfo extends \SplFileInfo |
| 5 | { |
| 6 | private $relativePath; |
| 7 | private $relativePathname; |
| 8 | public function __construct(string $file, string $relativePath, string $relativePathname) |
| 9 | { |
| 10 | parent::__construct($file); |
| 11 | $this->relativePath = $relativePath; |
| 12 | $this->relativePathname = $relativePathname; |
| 13 | } |
| 14 | public function getRelativePath() |
| 15 | { |
| 16 | return $this->relativePath; |
| 17 | } |
| 18 | public function getRelativePathname() |
| 19 | { |
| 20 | return $this->relativePathname; |
| 21 | } |
| 22 | public function getFilenameWithoutExtension() : string |
| 23 | { |
| 24 | $filename = $this->getFilename(); |
| 25 | return \pathinfo($filename, \PATHINFO_FILENAME); |
| 26 | } |
| 27 | public function getContents() |
| 28 | { |
| 29 | \set_error_handler(function ($type, $msg) use(&$error) { |
| 30 | $error = $msg; |
| 31 | }); |
| 32 | $content = \file_get_contents($this->getPathname()); |
| 33 | \restore_error_handler(); |
| 34 | if (\false === $content) { |
| 35 | throw new \RuntimeException($error); |
| 36 | } |
| 37 | return $content; |
| 38 | } |
| 39 | } |
| 40 |