Skip to content

Instantly share code, notes, and snippets.

View omarkdev's full-sized avatar

Marcos Felipe omarkdev

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