Last active
April 1, 2019 22:12
-
-
Save ancarebeca/d38ebfa4766eb2f9f12837d76d0e6cfd 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
<?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