-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #12 The functionality of adding tags has been redesigned
- Loading branch information
Showing
8 changed files
with
149 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
use M3uParser\Tag\ExtTagInterface; | ||
|
||
class Entry | ||
class M3uEntry | ||
{ | ||
protected $lineDelimiter = "\n"; | ||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace M3uParser; | ||
|
||
|
||
use M3uParser\Tag\ExtInf; | ||
use M3uParser\Tag\ExtTagInterface; | ||
use M3uParser\Tag\ExtTv; | ||
|
||
trait TagsManagerTrait | ||
{ | ||
private $tags = []; | ||
|
||
/** | ||
* Add tag | ||
* | ||
* @param string $tag class name must be implement ExtTagInterface interface | ||
* @return $this | ||
* @throws Exception | ||
*/ | ||
public function addTag($tag) | ||
{ | ||
if (!\in_array(ExtTagInterface::class, \class_implements($tag), true)) { | ||
throw new Exception(\sprintf('The class %s must be implement interface %s', $tag, ExtTagInterface::class)); | ||
} | ||
|
||
$this->tags[] = $tag; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Add default tags (EXTINF and EXTTV) | ||
* | ||
* @return $this | ||
* @throws Exception | ||
*/ | ||
public function addDefaultTags() | ||
{ | ||
$this->addTag(ExtInf::class); | ||
$this->addTag(ExtTv::class); | ||
return $this; | ||
} | ||
|
||
/** | ||
* Remove all previously defined tags | ||
* | ||
* @return $this | ||
*/ | ||
public function clearTags() | ||
{ | ||
$this->tags = []; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Get all active tags | ||
* | ||
* @return string[] | ||
*/ | ||
protected function getTags() | ||
{ | ||
return $this->tags; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.