Captioning\File::addCue PHP 메소드

addCue() 공개 메소드

Add a cue
public addCue ( mixed $_mixed, string $_start = null, string $_stop = null ) : File
$_mixed mixed An cue instance or a string representing the text
$_start string A timecode
$_stop string A timecode
리턴 File
    public function addCue($_mixed, $_start = null, $_stop = null)
    {
        $fileFormat = self::getFormat($this);
        // if $_mixed is a Cue
        if (is_object($_mixed) && class_exists(get_class($_mixed)) && class_exists(__NAMESPACE__ . '\\Cue') && is_subclass_of($_mixed, __NAMESPACE__ . '\\Cue')) {
            $cueFormat = Cue::getFormat($_mixed);
            if ($cueFormat !== $fileFormat) {
                throw new \Exception("Can't add a {$cueFormat} cue in a {$fileFormat} file.");
            }
            $_mixed->setLineEnding($this->lineEnding);
            $this->cues[] = $_mixed;
        } else {
            $cueClass = self::getExpectedCueClass($this);
            $cue = new $cueClass($_start, $_stop, $_mixed);
            $cue->setLineEnding($this->lineEnding);
            $this->cues[] = $cue;
        }
        return $this;
    }

Usage Example

예제 #1
0
 public function addCue($_mixed, $_start = null, $_stop = null)
 {
     if (get_class($_mixed) === self::getExpectedCueClass($this)) {
         if (null !== $_mixed->getStyle() && !isset($this->styles[$_mixed->getStyle()])) {
             throw new \InvalidArgumentException(sprintf('Invalid cue style "%s"', $_mixed->getStyle()));
         }
         if (null !== $_mixed->getRegion() && !isset($this->regions[$_mixed->getRegion()])) {
             throw new \InvalidArgumentException(sprintf('Invalid cue region "%s"', $_mixed->getRegion()));
         }
     }
     return parent::addCue($_mixed, $_start, $_stop);
 }