Skip to content

Instantly share code, notes, and snippets.

View drupol's full-sized avatar

Pol Dellaiera drupol

View GitHub Profile
class Foo {
public function izumi();
}
class Bar {
public function nakano();
}
class Foo implements FooInterface {}
class Bar implements BarInterface {}
<?php
class FooBar implements FooInterface, BarInterface {
public function __construct(FooInterface $foo, BarInterface $bar) {}
public function izumi() {
return $this->foo->izumi();
}
<?php
declare(strict_types=1);
namespace loophp\collection;
use ArrayAccess;
use ArrayIterator;
use ArrayObject;
use Countable;
@drupol
drupol / TextAnalysis.php
Created June 24, 2020 14:26
Run Text Analysis with loophp/collection.
<?php
declare(strict_types=1);
include __DIR__ . '/vendor/autoload.php';
use loophp\collection\Collection;
$collection = Collection::with(file_get_contents('http://loripsum.net/api'))
// Filter out some characters.
@drupol
drupol / random-number-distribution.php
Last active August 28, 2020 13:57
Random number distribution
<?php
declare(strict_types=1);
include 'vendor/autoload.php';
use loophp\collection\Collection;
use loophp\collection\Contract\Operation\Sortable;
$min = 0;
@drupol
drupol / parse-commit-log.php
Last active September 19, 2020 11:11
Parse commit log with loophp/collection
<?php
declare(strict_types=1);
include 'vendor/autoload.php';
use loophp\collection\Collection;
use loophp\collection\Contract\Collection as CollectionInterface;
$commandStream = static function (string $command): Generator {
@drupol
drupol / twinPrimeNumbers.php
Last active September 1, 2020 12:47
Sieve of Eratosthenes for finding Prime numbers and Twin Prime numbers
<?php
/**
* Run this code with: "php -n <file.php>" to make sure no configuration will be used
* so xdebug will not be used either.
*/
declare(strict_types=1);
include __DIR__ . '/vendor/autoload.php';