Skip to content

Instantly share code, notes, and snippets.

View jubianchi's full-sized avatar
🏳️‍🌈
nyan nyan nyan

Julien BIANCHI jubianchi

🏳️‍🌈
nyan nyan nyan
View GitHub Profile

Imaginons un systéme de billeterie obéissant aux rêgles suivantes :

  1. Un client peut acheter de 1 à n ticket;
  2. Un ticket est valable pour une et une seule personne;
  3. Le prix du ticket doit être 2 si la personne à moins de 4 ans, 10 si la personne à moins de 12 ans et 30 pour toute personne agée de plus de 12 ans.

Il nous est demandé de développer le code correspondant à cet ensemble de régles en obéissant aux paradigme de la programmation orientée objet.
Une implémentation possible pourrait être la suivante :

@Tapha
Tapha / oo.php
Created September 22, 2010 13:18 — forked from dhotson/oo.php
<?php
// Define the 'class' class
$class = Obj()
->fn('new', function ($class) {
$newClass = Obj($class->methods)
->fn('new', function($class) {
$obj = Obj($class->imethods);
$args = func_get_args();
array_shift($args);
@jbrumwell
jbrumwell / oo.php
Created September 23, 2010 18:56 — forked from dhotson/oo.php
<?php
// Define the 'class' class
$class = Obj()
->fn('new', function ($class) {
$newClass = Obj($class->methods)
->fn('new', function($class) {
$obj = Obj($class->imethods);
$args = func_get_args();
array_shift($args);
@CarterA
CarterA / gist:1257894
Created October 2, 2011 20:32
Better Singletons in Objective-C
@implementation Singleton
+ (Singleton *)sharedInstance {
static Singleton *globalInstance;
static dispatch_once_t predicate;
dispatch_once(&predicate, ^{
globalInstance = [[self alloc] init];
});
return globalInstance;
}
@everzet
everzet / ExceptionalClient.php
Created January 18, 2012 16:44
View real exceptions in Behat output with Mink+SymfonyDriver in your Symfony2 feature suite
<?php
namespace Your\MainBundle;
use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Component\HttpKernel\HttpKernelInterface;
class ExceptionalClient extends Client
{
static private $catchExceptions = true;
@cordoval
cordoval / WelcomeController.php
Created August 6, 2012 00:56 — forked from jmather/WelcomeController.php
How to scope out hierarchal structure in symfony2
<?php
namespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class WelcomeController extends Controller
{
public function indexAction()
{
@cordoval
cordoval / post_commit
Created August 17, 2012 19:39 — forked from marijn/post_commit
Post commit hook for a multiple branch Sismo setup.
#!/bin/sh
sismo --quiet build `git name-rev --name-only HEAD | xargs -I {} echo "Pink Tie/CoreBundle/{}" | tr '[A-Z]' '[a-z]' | tr "/" "-" | tr " " "-"` `git log -1 HEAD --pretty="%H"` &
@cordoval
cordoval / fix_symfony2_permissions.sh
Created August 21, 2012 04:42 — forked from kbond/fix_symfony2_permissions.sh
Fix Symfony2 Permissions
#!/bin/sh
USER=$(whoami)
APACHE_USER=$(ps axho user,comm|grep -E "httpd|apache"|uniq|grep -v "root"|awk 'END {print $1}')
sudo chmod +a "$USER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
sudo chmod +a "$APACHE_USER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
echo "app/cache & app/logs been properly chmod'ed for $USER and $APACHE_USER"
@cordoval
cordoval / CommandRunCommand.php
Created August 27, 2012 11:32 — forked from predakanga/CommandRunCommand.php
Code for running commands
<?php
/**
* The actual command which is used to call other commands
*/
class CommandRunCommand extends ContainerAwareCommand
{
protected function configure()
{
$this->setName("cmd:run")