| | ]; |
| | |
| | + private static $finfo; |
| | + |
| | private string $name; |
| | private string $sha; |
 |
| | $this->timestamp = $timestamp; |
| | $this->size = $size; |
| | - $this->isDir = $mode === self::MODE_DIR || $mode === self::MODE_DIR_LONG; |
| | + $this->isDir = $mode === self::MODE_DIR || |
| | + $mode === self::MODE_DIR_LONG; |
| | |
| | $buffer = $this->isDir ? '' : $contents; |
 |
| | } |
| | |
| | - public function highlight( FileRenderer $renderer, string $content ): string { |
| | + public function highlight( |
| | + FileRenderer $renderer, |
| | + string $content |
| | + ): string { |
| | return $renderer->highlight( $this->name, $content, $this->mediaType ); |
| | + } |
| | + |
| | + public function isDir(): bool { |
| | + return $this->isDir; |
| | } |
| | |
 |
| | |
| | private function detectMediaType( string $buffer ): string { |
| | + if( self::$finfo === null ) { |
| | + self::$finfo = new finfo( FILEINFO_MIME_TYPE ); |
| | + } |
| | + |
| | return $buffer === '' |
| | ? self::MEDIA_EMPTY |
| | - : ((new finfo( FILEINFO_MIME_TYPE ))->buffer( $buffer ) ?: |
| | - self::MEDIA_OCTET); |
| | + : (self::$finfo->buffer( $buffer ) ?: self::MEDIA_OCTET); |
| | } |
| | |