Skip to content

Instantly share code, notes, and snippets.

@IMSoP
Created June 7, 2020 13:47
Show Gist options
  • Save IMSoP/47488b87412ae4e2b1719d7e3a818c7d to your computer and use it in GitHub Desktop.
Save IMSoP/47488b87412ae4e2b1719d7e3a818c7d to your computer and use it in GitHub Desktop.
<?php
enum Boundaries
{
case INCLUDE_NONE(false, false);
case INCLUDE_START(true, false);
case INCLUDE_END(false, true);
case INCLUDE_ALL(true, true);
protected bool $startIncluded;
protected bool $endIncluded;
private function __construct($startIncluded, $endIncluded)
{
$this->startIncluded = $startIncluded;
$this->endIncluded = $endIncluded;
}
public function startIncluded(): bool
{
return $this->startIncluded;
}
public function endIncluded(): bool
{
return $this->endIncluded;
}
}
@IMSoP
Copy link
Author

IMSoP commented Jun 7, 2020

Example based on this blog post: https://stitcher.io/blog/enums-without-enums

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment