Skip to content

Instantly share code, notes, and snippets.

View vanbrabantf's full-sized avatar
😃

Frederick Vanbrabant vanbrabantf

😃
View GitHub Profile
<?php
class Collection<EntryType>
{
private $collection = [];
public function addValue(EntryType $item)
{
$this->collection[] = $item;
}
<?php
public function runBatch<T is Runnable>(T $batch) {
foreach ($batch as $entry) {
$entry->run(); // Runnable
}
}
<?php
public function resolve($toResolve)
{
if (is_callable($toResolve)) {
return $toResolve;
}
if (!is_string($toResolve)) {
$this->assertCallable($toResolve);
}
<?php
function resolve($toResolve)
{
if (is_callable($toResolve)) {
return $toResolve;
} else {
if (!is_string($toResolve)) {
$this->assertCallable($toResolve);
}
if (preg_match(self::CALLABLE_PATTERN, $toResolve, $m))
PATCH images/4
{
"width": 400,
"height": 200
}
POST images.crop-image
{
"id": 4,
"width": 400,
"height": 200
}
POST cropImage
{
"id": 4,
"width": 400,
"height": 200
}
POST displayUser
{
“Id”: 4
}
GET displayUser?id=4
<?php
public function mailUsers(Message $message)
{
$users = $this->userRespository->getUsers();
MailService::SendToUsers($users, $message);
}