Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/document/PhabricatorDocumentRef.php
<?php | <?php | ||||
final class PhabricatorDocumentRef | final class PhabricatorDocumentRef | ||||
extends Phobject { | extends Phobject { | ||||
private $name; | private $name; | ||||
private $mimeType; | private $mimeType; | ||||
private $file; | private $file; | ||||
private $byteLength; | private $byteLength; | ||||
private $snippet; | |||||
public function setFile(PhabricatorFile $file) { | public function setFile(PhabricatorFile $file) { | ||||
$this->file = $file; | $this->file = $file; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getFile() { | public function getFile() { | ||||
return $this->file; | return $this->file; | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | final class PhabricatorDocumentRef | ||||
} | } | ||||
private function normalizeMimeType($mime_type) { | private function normalizeMimeType($mime_type) { | ||||
$mime_type = trim($mime_type); | $mime_type = trim($mime_type); | ||||
$mime_type = phutil_utf8_strtolower($mime_type); | $mime_type = phutil_utf8_strtolower($mime_type); | ||||
return $mime_type; | return $mime_type; | ||||
} | } | ||||
public function isProbablyText() { | |||||
$snippet = $this->getSnippet(); | |||||
return (strpos($snippet, "\0") === false); | |||||
} | |||||
public function getSnippet() { | |||||
if ($this->snippet === null) { | |||||
$this->snippet = $this->loadData(null, (1024 * 1024 * 1)); | |||||
} | |||||
return $this->snippet; | |||||
} | |||||
} | } |