Untitled

mail@pastecode.io avatar
unknown
php_laravel_blade
2 years ago
1.2 kB
4
Indexable
Never
<?php

class ButtonFactory 
{
	public function create(string $type, string $link): ButtonInterface
	{
		// Logic to figure out which Button you want
	}
}

interface ButtonInteface
{
	public function link(): string;
	public function text(): string;
	public function hover(): string;
	public function toHtml(): string;
}

class LightButton implements ButtonInterface
{
	private string $link;
	private string $text;
	private string $hover;
	
	public function __construct(string $link)
	{
		$this->link = $link;
	}
	
	public function link()
	{
		return $this->link;
	}
	
	public function text()
	{
		return $this->text;
	}
	
	public function hover()
	{
		return $this->hover;
	}
	
	public function toHtml(): string
	{
		// How you want the A tag
	}
}

class DarkButton implements ButtonInterface
{
	private string $link;
	private string $text;
	private string $hover;
	
	public function __construct(string $link)
	{
		$this->link = $link;
	}
	
	public function link()
	{
		return $this->link;
	}
	
	public function text()
	{
		return $this->text;
	}
	
	public function hover()
	{
		return $this->hover;
	}
	
	public function toHtml(): string
	{
		// How you want the A tag
	}
}