Skip to content

Instantly share code, notes, and snippets.

@ancarebeca
Last active April 1, 2019 22:12
Show Gist options
  • Save ancarebeca/d38ebfa4766eb2f9f12837d76d0e6cfd to your computer and use it in GitHub Desktop.
Save ancarebeca/d38ebfa4766eb2f9f12837d76d0e6cfd to your computer and use it in GitHub Desktop.
<?php
class Book
{
private $title;
function __construct(string $title_in)
{
$this->title = $title_in;
}
function getTitle(): string
{
return $this->title;
}
public function formatTitle(string $format): string
{
switch ($format) {
case "uppercase":
return strtoupper($this->getTitle());
case "lowercase":
return strtolower($this->getTitle());
case "lcfirst":
return lcfirst($this->getTitle());
case "ucwords":
return ucwords($this->getTitle());
default:
return $this->getTitle();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment