Created
May 14, 2016 12:20
-
-
Save acepsaepudin/a55074f03fcf40ad7f29a268f50a213d 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 Buku | |
* @author Acep Saepudin | |
*/ | |
class Buku | |
{ | |
private $penulis = 'Acep Saepudin'; | |
private $judul = 'Cara cepat kaya dengan begadang'; | |
/** | |
* Creator dengan static function | |
* | |
* @return instance of the object | |
*/ | |
public static function make() | |
{ | |
$buku = new Buku(); | |
return $buku; | |
} | |
/** | |
* Chain | |
* | |
* @return object | |
*/ | |
public function penulis($penulis) | |
{ | |
$this->penulis = $penulis; | |
return $this; | |
} | |
/** | |
* Chain | |
* | |
* @return object | |
*/ | |
public function judul($judul) | |
{ | |
$this->judul = $judul; | |
return $this; | |
} | |
/** | |
* trigger | |
* | |
* @return string | |
*/ | |
public function save() | |
{ | |
return "Buku {$this->judul} dengan penulis {$this->penulis} telah disimpan ke database.\n"; | |
} | |
} | |
echo Buku::make()->save(); | |
echo Buku::make()->penulis('Sibuta dari gua elu')->judul('saya suka laravel karena warnanya merah merona')->save(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment