Skip to content

Instantly share code, notes, and snippets.

@dwihujianto
Created October 17, 2017 11:15
Show Gist options
  • Select an option

  • Save dwihujianto/1bbbae57fb265cc8d1e44179ccaece9b to your computer and use it in GitHub Desktop.

Select an option

Save dwihujianto/1bbbae57fb265cc8d1e44179ccaece9b to your computer and use it in GitHub Desktop.
<?php
$app = new TestApplication;
$app->run();
class TestApplication
{
public function run()
{
$post = new Post("Tutorial membuat CRUD dengan Laravel: [youtube id=HmV4gXIkP6k]");
echo $post->getHtmlContent();
$post = new Post("Tutorial membuat CRUD dengan Laravel: [youtube id=HmV4gXIkP6k]" .
"Contoh kode bisa dilihat di bawah ini: [gist id=9fdb82372bd10b5627e0]");
echo $post->getHtmlContent();
}
}
class Post
{
protected $content;
public function __construct($content)
{
$this->content = $content;
$methods = get_class_methods($this);
foreach ($methods as $method) {
if ($method == '__construct' || $method == 'getHtmlContent') {
continue;
}
$this->{$method}();
}
}
public function getHtmlContent()
{
return $this->content;// YOUR CODE HERE
}
public function shortYoutube()
{
if (strpos($this->content, '[youtube id=')) {
return str_replace('number link', 'embeded link', $this->content);
}
}
public function shortGist()
{
if (strpos($this->content, 'gist id=')) {
return str_replace('number link', 'embeded link', $this->content);
}
}
// JUST WRITE OTHER FUNCTION IF NEED TO TRANSLATE NEW SHORTTAG
}
// OR HERE, IF YOU REALLY NEED TO WRITE ANOTHER FUNCTION OR CLASS OR INTERFACE OR TRAIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment