Created
August 20, 2021 22:23
-
-
Save jzawadzki/a9e4843e59d4cd877c3cea0377fb64ed to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
class Hello { | |
private string $url; | |
private function __construct() {} | |
public function getUrl(): string { | |
return $this->url; | |
} | |
public static function fromArray(array $row): self { | |
$hello = new Hello; | |
$hello->url = $row['url']; | |
return $hello; | |
} | |
} | |
$hello = Hello::fromArray(['url'=>'https://medium.com']); | |
echo $hello->getUrl(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment