This file contains hidden or 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 Buyer { | |
protected $name; | |
protected $purchases; | |
public function addNewPurchase() | |
{ | |
$this->purchases++; | |
} |
This file contains hidden or 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 Buyer { | |
protected $name; | |
protected $purchases; | |
public function getName() {/**/} | |
public function setName($name) {/**/} | |
public function getPurchases() {/**/} |
This file contains hidden or 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 Email { | |
public $email; | |
public function __construct($email) | |
{ | |
if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) { | |
throw new InvalidEmailException; | |
} |
This file contains hidden or 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 Order | |
{ | |
public function notifyBuyer($email) | |
{ | |
if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) { | |
throw new InvalidEmailException; | |
} | |
return $this->repository->sendEmail($email); |
This file contains hidden or 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 | |
protected function indexAction() | |
{ | |
if ($this->security->isGranted('ADMIN')) { | |
return $this->render('admin/index.html.twig'); | |
} | |
return $this->render('home/access_denied.html.twig'); | |
} |
This file contains hidden or 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 | |
protected function indexAction() | |
{ | |
if ($this->security->isGranted('ADMIN')) { | |
$view = 'admin/index.html.twig'; | |
} else { | |
$view = 'home/access_denied.html.twig'; | |
} |
This file contains hidden or 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 | |
public function show($slug) | |
{ | |
$lesson = $this->repository->findBySlug($slug); | |
if ($lesson) { | |
$this->addThumbToImages($lesson->thumb_url); | |
$trackTitle = ! $lesson->track ? '' : '['.$lesson->track->title.']'; |
This file contains hidden or 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 | |
public function show($slug) | |
{ | |
$lesson = $this->repository->findBySlug($slug); | |
if ($lesson) { | |
if (!empty($lesson->thumb_url)) { | |
$this->seo()->addImages($lesson->thumb_url); | |
} |
This file contains hidden or 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
#!/bin/bash | |
ask_yesno() { | |
question="$1 [y|N] " | |
read -p "$question" answer | |
if [[ -z $answer ]] | |
then | |
answer=n |
This file contains hidden or 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 | |
if (!function_exists('array_to_object')) { | |
function array_to_object(Array $data) | |
{ | |
$data = array_map( function ($item) { | |
if (is_array($item)) { | |
$item = array_to_object($item); | |
} |