Move blob size loading to strategy
[gitphp.git] / include / git / blob / BlobLoad_Git.class.php
blob:a/include/git/blob/BlobLoad_Git.class.php -> blob:b/include/git/blob/BlobLoad_Git.class.php
--- a/include/git/blob/BlobLoad_Git.class.php
+++ b/include/git/blob/BlobLoad_Git.class.php
@@ -7,28 +7,8 @@
  * @package GitPHP
  * @subpackage Git\Blob
  */
-class GitPHP_BlobLoad_Git implements GitPHP_BlobLoadStrategy_Interface
+class GitPHP_BlobLoad_Git extends GitPHP_BlobLoad_Base
 {
-	/**
-	 * Executable
-	 *
-	 * @var GitPHP_GitExe
-	 */
-	protected $exe;
-
-	/**
-	 * Constructor
-	 *
-	 * @param GitPHP_GitExe $exe executable
-	 */
-	public function __construct($exe)
-	{
-		if (!$exe)
-			throw new Exception('Git exe is required');
-
-		$this->exe = $exe;
-	}
-
 	/**
 	 * Gets the data for a blob
 	 *
@@ -40,11 +20,8 @@
 		if (!$blob)
 			return;
 
-		$args = array();
-		$args[] = 'blob';
-		$args[] = $blob->GetHash();
-
-		return $this->exe->Execute($blob->GetProject()->GetPath(), GIT_CAT_FILE, $args);
+		$result = $this->exe->GetObjectData($blob->GetProject()->GetPath(), $blob->GetHash());
+		return $result['contents'];
 	}
 
 	/**
@@ -55,14 +32,7 @@
 	 */
 	public function Size($blob)
 	{
-		if (!$blob)
-			return;
-
-		$args = array();
-		$args[] = '-s';
-		$args[] = $blob->GetHash();
-
-		return $this->exe->Execute($blob->GetProject()->GetPath(), GIT_CAT_FILE, $args);
+		return $this->LoadSize($blob);
 	}
 }
 

comments