Skip to content

Instantly share code, notes, and snippets.

Avatar

Pol Dellaiera drupol

View GitHub Profile
@drupol
drupol / OracleQuoteStrategy.php
Created Feb 12, 2021
Doctrine Oracle Quote Strategy
View OracleQuoteStrategy.php
<?php
declare(strict_types=1);
namespace App\Doctrine;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\QuoteStrategy;
View CasGuard.php
<?php
declare(strict_types=1);
namespace loophp\LaravelCas\Guards;
use EcPhp\CasLib\CasInterface;
use Illuminate\Auth\GuardHelpers;
use Illuminate\Auth\SessionGuard;
use Illuminate\Contracts\Auth\UserProvider;
@drupol
drupol / primes.php
Last active Dec 30, 2020
Generating Prime Numbers with loophp/collection
View primes.php
<?php
declare(strict_types=1);
include __DIR__ . '/../vendor/autoload.php';
use loophp\collection\Collection;
$integers = Collection::unfold(static fn (int $n = 1): int => $n + 1);
View exitTheUs.php
<?php
declare(strict_types=1);
namespace App;
include __DIR__ . '/../vendor/autoload.php';
use loophp\collection\Collection;
@drupol
drupol / wallis.php
Last active Feb 25, 2021
Find Pi using Wallis formula
View wallis.php
<?php
/**
* Wallis formula
*
* 2 2 4 4 6 6 8 8
* pi = 2 x --- x --- x --- x --- x --- x --- x --- x --- x ...
* 1 3 3 5 5 7 7 9
*/
@drupol
drupol / stream-iterator.php
Last active Dec 9, 2020
Stream Iterator oddity
View stream-iterator.php
<?php
declare(strict_types=1);
namespace App;
use Generator;
use Iterator;
class ClosureIterator implements \Iterator
@drupol
drupol / SqliteForeignKeyEnabler.php
Created Dec 4, 2020
SqliteForeignKeyEnabler.php
View SqliteForeignKeyEnabler.php
<?php
declare(strict_types=1);
namespace App\Doctrine;
use Doctrine\Common\EventSubscriber;
use Doctrine\DBAL\Events;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Event\PreFlushEventArgs;
View FinYears.php
<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\FinYearsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
@drupol
drupol / fibonacci.php
Last active Nov 29, 2020
Fibonacci / Memoization / Solution
View fibonacci.php
<?php
declare(strict_types=1);
namespace App;
use ArrayObject;
use Closure;
use Generator;
View TestString.php
<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\TestStringRepository;
use Doctrine\ORM\Mapping as ORM;