Skip to content

Instantly share code, notes, and snippets.

@acepsaepudin
Created May 14, 2016 12:20
Show Gist options
  • Save acepsaepudin/a55074f03fcf40ad7f29a268f50a213d to your computer and use it in GitHub Desktop.
Save acepsaepudin/a55074f03fcf40ad7f29a268f50a213d to your computer and use it in GitHub Desktop.
<?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