Skip to content

Instantly share code, notes, and snippets.

View ronan-gloo's full-sized avatar

Ronan ronan-gloo

  • ShoppingFeed
  • France
View GitHub Profile
<?php
$connection = new \AMQPConnection([
'host' => '127.0.0.1',
'login' => 'guest',
'password' => 'guest',
'port' => 5672,
'vhost' => '/',
]);
<?php
interface Adapter
{
public function init($required);
}
// Warning: caller will pass 2 argument
class NotOk implements Adapter
{
public function init($required){}
@ronan-gloo
ronan-gloo / i-extend-charlie.php
Last active January 4, 2016 14:01
I extend Charlie
<?php
class Charlie
{
/**
* @deprecated
*/
final public function __destruct()
{
throw new NonRealisticCallException('Sorry, we are unable to complete your request');
@ronan-gloo
ronan-gloo / gist:e4f963915ab62f6bcf23
Last active August 29, 2015 14:08
unserialize callback
<?php
function unserialize_callback($className) {
if (! class_exists($className)) {
throw new RuntimeException('class not found: ' . $className);
} else {
throw new RuntimeException('deserialization of ' . $className . ' failed');
}
}
@ronan-gloo
ronan-gloo / PrgDev.php
Created April 24, 2014 08:12
Prg for devmode
<?php
namespace Application\Controller\Plugin;
use Zend\Mvc\Controller\Plugin\AbstractPlugin;
/**
* Use this object to replace the original prg controller's plugin for dev convenience.
*/
@ronan-gloo
ronan-gloo / gist:9342993
Created March 4, 2014 09:17
Cuisine et dépendances
<?php
// constructor
class Void
{
protected $mapper;
public function __construct(Mapper $mapper)
{
$this->mapper = $mapper;
@ronan-gloo
ronan-gloo / gist:9291902
Last active August 29, 2015 13:56
Scope varaible + méthode
<?php
class User {
private $password;
public function __construct($password)
{
$this->password = $password;
}
<?php
class SoapClient
{
public function __call($method, $args)
{
return $this;
}
public function __get($prop)
@ronan-gloo
ronan-gloo / gist:6278100
Last active December 21, 2015 08:28
ATOUM: Get last error in exception callback
<?php
function toto($pattern, $value) {
$split = preg_split($pattern, $value);
if ($error = error_get_last()) {
throw new Exception($error['message'], Exception::INVALID_PARAMETER);
}
}
@ronan-gloo
ronan-gloo / gist:6071752
Created July 24, 2013 15:41
Gestion 404 dans les controleurs
<?php
// Remplacer:
if (!$page) {
$response = new Response();
$response->setStatusCode(404);
return $response;
}
// Par: