entity->header()->encode(), $this->entity->logicalScreenDescriptor()->encode(), $this->maybeEncodeGlobalColorTable(), $this->encodeFrames(), $this->encodeComments(), $this->entity->trailer()->encode(), ]); } /** * Decode global color table if present in gif data. */ private function maybeEncodeGlobalColorTable(): string { if (!$this->entity->hasGlobalColorTable()) { return ''; } return $this->entity->globalColorTable()->encode(); } /** * Encode data blocks of source. * * @throws EncoderException */ private function encodeFrames(): string { return implode('', array_map( fn(FrameBlock $frame): string => $frame->encode(), $this->entity->frames(), )); } /** * Encode comment extension blocks of source. * * @throws EncoderException */ private function encodeComments(): string { return implode('', array_map( fn(CommentExtension $commentExtension): string => $commentExtension->encode(), $this->entity->comments() )); } }