13-builder.php 609 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace cx_newsletter;
  3. abstract class builder
  4. implements builder_interface {
  5. public function __construct() {
  6. $this->completed = false;
  7. $this->target = null;
  8. $this->prepare();
  9. }
  10. protected abstract function prepare() : void;
  11. protected function complete() : void {
  12. $this->completed = true;
  13. }
  14. public function get() : mixed {
  15. return $this->target;
  16. }
  17. public function is_complete() : bool {
  18. return $this->target !== null and $this->completed;
  19. }
  20. protected bool $completed;
  21. protected mixed $target;
  22. }