1. Go to this page and download the library: Download gobline/presenter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gobline / presenter example snippets
class Property
{
protected $price;
protected $nbRooms;
protected $livingArea;
protected $publicationDate;
public function __construct($price, $nbRooms, $livingArea)
{
$this->price = $price;
$this->nbRooms = $nbRooms;
$this->livingArea = $livingArea;
$this->publicationDate = new \DateTime();
}
public function getPrice() { return $this->price; }
public function getNbRooms() { return $this->nbRooms; }
public function getLivingArea() { return $this->livingArea; }
public function getPublicationDate() { return $this->publicationDate; }
}
$property = new Property(650, 1, 120);
$property = new Gobline\Presenter\Presenter($property);
class PropertyPresenter extends Gobline\Presenter\Presenter
{
public function __construct(Property $subject)
{
parent::__construct($subject);
}
public function getPublicationDate()
{
return $this->subject->getPublicationDate()->format('d/m/Y');
}
public function getNbRooms()
{
$nbRooms = $this->subject->getNbRooms();
if ($nbRooms === 0) {
return 'Studio';
}
if ($nbRooms === 1) {
return $nbRooms.' room';
}
return $nbRooms.' rooms';
}
}
$property = new Property(650, 1, 120);
$property = new PropertyPresenter($property);
use Gobline\Translator\Translator;
class PropertyPresenterFactory implements Gobline\Presenter\PresenterFactoryInterface
{
protected $translator;
public function __construct(Translator $translator)
{
$this->translator = $translator;
}
public function createPresenter($property)
{
return new PropertyPresenter($property, $this->translator);
}
}