Last active
August 29, 2015 14:24
-
-
Save AD7six/dc17c2e1f7d7c14ecbd4 to your computer and use it in GitHub Desktop.
A simple presenter example based on CakePHP 2 code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Dummy extends Model { | |
public function price() { | |
return (float)1,234.56; // db stored value | |
} | |
} | |
class DummyPresenter { | |
protected $model; | |
function __construct(Dummy $modelInstance) { | |
$this->model = $modelInstance; | |
} | |
function price() { | |
return money_format('%i', $this->model->price()); // the value as it should be shown | |
} | |
} | |
$model = [ find it ]; | |
$presenter = new DummyPresenter($model); | |
echo $presenter->price(); // USD 1,234.56 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment