Skip to content

Instantly share code, notes, and snippets.

@vojtasvoboda
Last active October 3, 2015 13:58
Show Gist options
  • Save vojtasvoboda/2464594 to your computer and use it in GitHub Desktop.
Save vojtasvoboda/2464594 to your computer and use it in GitHub Desktop.
Lazy getter
<?php
class HomepagePresenter extends BasePresenter
{
/** @var EntriesModel */
protected $entriesModel;
/**
* Lazy getter for EntriesModel
* @return EntriesModel
*/
public function getEntries()
{
if ($this->entriesModel === NULL)
$this->entriesModel = new EntriesModel();
return $this->entriesModel;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment