1
0
Fork 0

Make ArrayRepository more extensible

pull/1/head
Jordi Boggiano 2011-04-18 00:12:40 +02:00
parent c6321e7277
commit 2475ce47e4
1 changed files with 12 additions and 1 deletions

View File

@ -21,7 +21,7 @@ use Composer\Package\PackageInterface;
*/ */
class ArrayRepository implements RepositoryInterface class ArrayRepository implements RepositoryInterface
{ {
protected $packages = array(); protected $packages;
/** /**
* Adds a new package to the repository * Adds a new package to the repository
@ -41,6 +41,9 @@ class ArrayRepository implements RepositoryInterface
*/ */
public function getPackages() public function getPackages()
{ {
if (null === $this->packages) {
$this->initialize();
}
return $this->packages; return $this->packages;
} }
@ -53,4 +56,12 @@ class ArrayRepository implements RepositoryInterface
{ {
return count($this->packages); return count($this->packages);
} }
/**
* Initializes the packages array. Mostly meant as an extension point.
*/
protected function initialize()
{
$this->packages = array();
}
} }