Skip to content

Instantly share code, notes, and snippets.

Charles cspray

Block or report user

Report or block cspray

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View enum-compass-values.php
<?php
namespace YourNamespace\Enums;
use Cspray\Yape\Enum;
use Cspray\Yape\EnumTrait;
final class Compass implements Enum {
use EnumTrait;
View enum-example.php
<?php
require_once __DIR__ . '/vendor/autoload.php';
use YourNamespace\Enums\Compass;
$north = Compass::North();
$south = Compass::South();
$east = Compass::East();
$west = Compass::West();
View keybase.md

Keybase proof

I hereby claim:

  • I am cspray on github.
  • I am cspray (https://keybase.io/cspray) on keybase.
  • I have a public key ASDgKvQd1ACmkJh6ME2WlXVdnigsEpwUUTk4BZF5Xbbjrwo

To claim this, I am signing this object:

@cspray
cspray / EchoCommand.php
Last active Sep 22, 2019
cspray/websocket-commands Quick Start
View EchoCommand.php
<?php
namespace MyApp\Command;
use Amp\Promise;
use Amp\Websocket\Client;
use Cspray\WebsocketCommands\ClientPayload;
use Cspray\WebsocketCommands\WebsocketCommand;
use function Amp\Promise\call;
View expecting-exception-async.txt
PHPUnit 6.5.14 by Sebastian Bergmann and contributors.
E.F 3 / 3 (100%)
Time: 132 ms, Memory: 4.00MB
There was 1 error:
1) Amp\PHPUnit\Test\AsyncTestCaseTest::testThatMethodRunsInLoopContext
Error: Loop exceptionally stopped without resolving the promise
@cspray
cspray / aysnc-test-example.php
Created Feb 9, 2019
AsyncTestCase example with amphp
View aysnc-test-example.php
<?php
// We assume that your PHPUnit bootstrap will include the appropriate class loader and setup your environment
use Amp\Delayed;
use Amp\Promise;
use Amp\PHPUnit\AsyncTestCase;
use function Amp\call;
View 01-async-test-case.php
<?php
abstract class AsyncTestCase extends \PHPUnit\Framework\TestCase {
public function runTest() {
Loop::run(function() {
$watcherId = Loop::delay(1500, function() {
Loop::stop();
$this->fail('The asynchronous test was expected to finish before the 1500 millisecond time limit');
});
@cspray
cspray / php-ds-stubs.php
Created Jun 26, 2016
A gist to create a PHP class for stubbing from a classname
View php-ds-stubs.php
<?php
declare(strict_types = 1);
/**
* @license See LICENSE file in project root
*/
require_once '/spraybot-app/vendor/autoload.php';
@cspray
cspray / route-handlers.php
Created Aug 23, 2015
Labrador HTTP - Possible Route Handlers
View route-handlers.php
<?php
use Symfony\Component\HttpFoundation\Response;
// Have a simple enough Response? No fuss, no muss just pass a Response object
$engine->get('/', new Response('Hello World'));
// Need something a tad more advanced? How about an anonymous functions!
$engine->get('/', function() {
return new Response('Hello World');
@cspray
cspray / labrador-quick-start.php
Last active Aug 29, 2015
labrador.cspray.net quick-start example
View labrador-quick-start.php
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Cspray\Labrador\Services;
use Cspray\Labrador\Engine;
use Cspray\Labrador\Event\ExceptionThrownEvent;
/** @var Auryn\Injector $injector */
$injector = (new Services)->createInjector();
You can’t perform that action at this time.