Skip to content

Instantly share code, notes, and snippets.

@jzawadzki
Created August 20, 2021 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jzawadzki/a9e4843e59d4cd877c3cea0377fb64ed to your computer and use it in GitHub Desktop.
Save jzawadzki/a9e4843e59d4cd877c3cea0377fb64ed to your computer and use it in GitHub Desktop.
<?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