1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | <?php /** * Base class for ref objects * * @author Christopher Han <xiphux@gmail.com> * @copyright Copyright (c) 2010 Christopher Han * @package GitPHP * @subpackage Git */ abstract class GitPHP_Ref extends GitPHP_GitObject { /** * The ref name * * @var string */ protected $refName; /** * The ref directory * * @var string */ protected $refDir; /** * Instantiates ref * * @param GitPHP_Project $project the project * @param string $refDir the ref directory * @param string $refName the ref name * @param string $refHash the ref hash */ public function __construct($project, $refDir, $refName, $refHash = '') { $this->project = $project; $this->refDir = $refDir; $this->refName = $refName; if (!empty($refHash)) { $this->SetHash($refHash); } } /** * Gets the ref name * * @return string ref name */ public function GetName() { return $this->refName; } /** * Gets the ref directory * * @return string ref directory */ public function GetDirectory() { return $this->refDir; } /** * Gets the path to the ref within the project * * @return string ref path */ public function GetRefPath() { return 'refs/' . $this->refDir . '/' . $this->refName; } /** * Gets the path to the ref including the project path * * @return string full ref path */ public function GetFullPath() { return $this->GetProject()->GetPath() . '/' . $this->GetRefPath(); } /** * Called to prepare the object for serialization * * @return string[] list of properties to serialize */ public function __sleep() { $properties = array('refName', 'refDir'); return array_merge($properties, parent::__sleep()); } } |