| Total Complexity | 3 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 12 | abstract class Playlist |
||
| 13 | { |
||
| 14 | |||
| 15 | const TYPE_M3U = 'm3u'; |
||
| 16 | const TYPE_XSPF = 'xspf'; |
||
| 17 | const TYPE_PLS = 'pls'; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var PlaylistItem[] the playlist items |
||
| 21 | */ |
||
| 22 | protected $_items = array(); |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var string the playlist filename |
||
| 26 | */ |
||
| 27 | private $_fileName; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @return string the file extension of the playlist |
||
| 31 | */ |
||
| 32 | abstract public function getExtension(); |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @return string the MIME type of the playlist |
||
| 36 | */ |
||
| 37 | abstract public function getMIMEType(); |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @return string the actual playlist data |
||
| 41 | */ |
||
| 42 | abstract public function __toString(); |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Class constructor |
||
| 46 | * @param string $fileName the playlist filename |
||
| 47 | */ |
||
| 48 | public function __construct($fileName) |
||
| 49 | { |
||
| 50 | $this->_fileName = $fileName; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Adds an item to the playlist |
||
| 55 | * @param PlaylistItem $item the item |
||
| 56 | */ |
||
| 57 | public function addItem($item) |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Returns the filename sanitized to minimize issues with various platforms |
||
| 64 | * @return string the sanitized filename |
||
| 65 | */ |
||
| 66 | public function getSanitizedFileName() |
||
| 69 | } |
||
| 70 | |||
| 72 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: