1. Go to this page and download the library: Download phunkie/phunkie-adt library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
interface Weekday {}
final class Sunday implements Weekday { }
final class Monday implements Weekday { }
//...
function orderPizza(Weekday $weekday, Pizza $pizza)
{
switch (get_class($weekday)) {
case Wednesday::class : return new WednesdayPromotionOrder($pizza);
default : return new Order($pizza);
}
}
final class Plutoday implements Weekday { }
abstract class Weekday implements TypeConstructor { use SumType; }
abstract class Weekday extends ImmutableSealed implements TypeConstructor { use SumType; }
abstract class Weekday extends ImmutableSealed implements TypeConstructor, SumTypeTag {
const sealedTo = [ Sunday::class, Monday::class, Tuesday::class,
Wednesday::class, Thursday::class, Friday::class, Saturday::class];
public function __construct() { $this->applySeal(); }
}
final class Sunday extends Weekday { use SumType; const typeConstructor = Weekday::class; }
final class Monday extends Weekday { use SumType; const typeConstructor = Weekday::class; }
//...
final class Saturday extends Weekday { use SumType; const typeConstructor = Weekday::class; }
final class Plotoday extends Weekday { use SumType; const typeConstructor = Weekday::class; }
new Plutoday; // results in:
// TypeError has been thrown with message: "Weekday is sealed and cannot be extended outside seal."
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.