Skip to content

Instantly share code, notes, and snippets.

View matthiasnoback's full-sized avatar

Matthias Noback matthiasnoback

View GitHub Profile
@matthiasnoback
matthiasnoback / quantities.php
Last active April 17, 2018 18:06
Modeling exercise: Quantities
<?php
// provided as method arguments:
$quantityInCurrentDelivery = 10.0;
// product-specific:
$quantityPrecision = 5;
// these quantities are all floats:
$quantityInitiallyOrdered = 12.5;
@matthiasnoback
matthiasnoback / convert.php
Last active April 17, 2018 18:06
Modeling exercise: currency conversion
<?php
declare(strict_types=1);
function convert(string $from, string $to, float $amount)
{
$exchangeRates = [
'USD,EUR' => 1.240055,
// ...
];
@matthiasnoback
matthiasnoback / EloquentModelAttributesRule.php
Created March 8, 2022 12:40
PHPStan rule and test combined
<?php
declare(strict_types=1);
namespace Utils\PHPStan;
use Generator;
use Illuminate\Database\Eloquent\Model;
use PhpParser\Node;
use PhpParser\Node\Expr\PropertyFetch;