Created
October 10, 2017 11:51
-
-
Save anonymous/c7c275305a57b5391f5c5d32efe40132 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
{ | |
... | |
protected $portfolioUrl; | |
public function setPortfolioUrl(string $url) | |
{ | |
if (false === filter_var($url, FILTER_VALIDATE_URL)) { | |
throw new InvalidURL($url); | |
} | |
$this->portfolioUrl = $url; | |
} | |
public function getPortfolioUrl():string | |
{ | |
return $this->portfolioUrl; | |
} | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
{ | |
... | |
protected $portfolioUrl; | |
public function setPortfolioUrl(Url $url) | |
{ | |
$this->portfolioUrl = $url; | |
} | |
public function getPortfolioUrl():Url | |
{ | |
return $this->portfolioUrl; | |
} | |
... | |
} | |
class Url | |
{ | |
protected $url; | |
public function setUrl(string $url) | |
{ | |
if (false === filter_var($url, FILTER_VALIDATE_URL)) { | |
throw new InvalidURL($url); | |
} | |
$this->url = $url; | |
} | |
public function getUrl():string | |
{ | |
return $this->url; | |
} | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
{ | |
... | |
const SINGLE = ‘S’; | |
const IN_RELATIONSHIP = ‘R’; | |
protected $relationship; | |
public function setRelationship(string $relationship) | |
{ | |
$this->relationship = $relationship; | |
} | |
public function getRelationship():string | |
{ | |
return $this->relationship; | |
} | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
{ | |
... | |
protected $relationship; | |
public function setRelationship(Relationship $relationship) | |
{ | |
$this->relationship = $relationship; | |
} | |
public function getRelationship():Relationship | |
{ | |
return $this->relationship; | |
} | |
... | |
} | |
class Relationship | |
{ | |
private $relationshipCode; | |
private function __construct($relationshipCode) | |
{ | |
$this->relationshipCode = $relationshipCode; | |
} | |
public function getRelationshipCode() | |
{ | |
return $this->relationshipCode; | |
} | |
public static function single():Relationship | |
{ | |
return new self('S'); | |
} | |
public static function inRelationship():Relationship | |
{ | |
return new self('R'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Offer | |
{ | |
... | |
const DRAFT = 1; | |
const PUBLISHED = 2; | |
const CANCELED = 3; | |
... | |
protected $status; | |
public function setStatus(int $status) | |
{ | |
$this->status = $status; | |
} | |
public function getStatus():int | |
{ | |
return $this->status; | |
} | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Offer | |
{ | |
... | |
const DRAFT = 1; | |
const PUBLISHED = 2; | |
Const CANCELLED = 3; | |
... | |
protected $status; | |
public function setStatus(OfferStatus $status) | |
{ | |
$this-status = $status; | |
} | |
public function getStatus():OfferStatus | |
{ | |
return $this->status; | |
} | |
... | |
} | |
abstract class OfferStatus | |
{ | |
public abstract function getCode(); | |
} | |
class DraftOffer extends OfferStatus | |
{ | |
public function getCode() | |
{ | |
return Offer::DRAFT; | |
} | |
} | |
class PublishedOffer extends OfferStatus | |
{ | |
public function getCode() | |
{ | |
return Offer::PUBLISHED; | |
} | |
} | |
class CancelledOffer extends OfferStatus | |
{ | |
public function getCode() | |
{ | |
return Offer::CANCELLED; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$todo = []; | |
$todo[0][‘description’] = ‘feed cat’; | |
$todo[0][‘done’] = true; | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Todo | |
{ | |
protected $description; | |
protected $done; | |
public function __construct(string $description, bool $done) | |
{ | |
$this->description = $description; | |
$this->done = $done; | |
} | |
public function setDone(bool $done) | |
{ | |
$this->done = $done; | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment