4 * Represents a binary large object in Git, usually a file in a tree.
8 const DEFAULT_MIME_TYPE
= 'text/plain';
10 * Instance of Git_Repo.
19 * Creates an unbaked Blob containing just the specified attributes.
21 public function __construct($repo, $kwargs) {
23 foreach ($kwargs as $k => $v) {
28 * Size of this blob in bytes.
30 public function size() {
31 if (is_null($this->_size
)) {
32 $this->_size
= (int) $this->repo
->git
->catFile($this->id
, array('s' => true));
37 * Returns the binary contents of this blob.
39 public function data() {
40 if (is_null($this->_data
)) {
41 $this->_data
= $this->repo
->git
->catFile($this->id
, array('p' => true));
45 // This function isn't implemented because we don't really have a
46 // good MIME implementation by default on PHP. Will implement after
47 // more investigation.
48 // public function mimeType() {
50 * Basename of this blob.
52 public function basename() {
53 return basename($this->__get('name'));
55 // public static function blame($repo, $commit, $file) {
56 public function __toString() {
57 return '(Git_Blob "' . $this->id
. '")';
59 public function __get($name) {
60 if (method_exists($this, $name)) return $this->$name();
61 else return $this->$name;