Applied fixes from StyleCI

This commit is contained in:
Pachira 2015-12-02 09:40:28 -05:00
parent 9aaf4877d9
commit d1b6808bef
6 changed files with 25 additions and 15 deletions

View file

@ -19,7 +19,8 @@ class BBcode
private $bbcode;
// Constructor
public function __construct($text = null) {
public function __construct($text = null)
{
// Create new parser class
$this->bbcode = new Parser();
@ -33,7 +34,8 @@ class BBcode
}
// Add basic bbcodes
public function loadStandardCodes() {
public function loadStandardCodes()
{
// Add the standard definitions
$this->bbcode->addCodeDefinitionSet(new DefaultCodeDefinitionSet());
@ -86,22 +88,26 @@ class BBcode
}
// Set text
public function text($text) {
public function text($text)
{
$this->bbcode->parse($text);
}
// Get as HTML
public function toHTML() {
public function toHTML()
{
return nl2br($this->bbcode->getAsHtml());
}
// Get as BBmarkup
public function toEditor() {
public function toEditor()
{
return $this->bbcode->getAsBBCode();
}
// Get as plaintext
public function toPlain() {
public function toPlain()
{
return $this->bbcode->getAsText();
}
}

View file

@ -9,7 +9,8 @@ use JBBCode\Parser;
use JBBCode\CodeDefinition;
use JBBCode\ElementNode;
class Align extends CodeDefinition {
class Align extends CodeDefinition
{
public function __construct()
{
parent::__construct();
@ -27,7 +28,7 @@ class Align extends CodeDefinition {
$content = "";
foreach($el->getChildren() as $child) {
foreach ($el->getChildren() as $child) {
$content .= $child->getAsHTML();
}

View file

@ -9,7 +9,8 @@ use JBBCode\Parser;
use JBBCode\CodeDefinition;
use JBBCode\ElementNode;
class Code extends CodeDefinition {
class Code extends CodeDefinition
{
public function __construct()
{
parent::__construct();

View file

@ -39,7 +39,7 @@ class Lists extends CodeDefinition
$listPieces = explode('[*]', $bodyHtml);
unset($listPieces[0]);
$listPieces = array_map(function($li) {
$listPieces = array_map(function ($li) {
return '<li>'.$li.'</li>';
}, $listPieces);
return '<ul>'.implode('', $listPieces).'</ul>';

View file

@ -9,7 +9,8 @@ use JBBCode\Parser;
use JBBCode\CodeDefinition;
use JBBCode\ElementNode;
class Size extends CodeDefinition {
class Size extends CodeDefinition
{
public function __construct()
{
parent::__construct();
@ -24,7 +25,7 @@ class Size extends CodeDefinition {
$content = "";
foreach($el->getChildren() as $child) {
foreach ($el->getChildren() as $child) {
$content .= $child->getAsHTML();
}

View file

@ -10,7 +10,8 @@ use JBBCode\Parser;
use JBBCode\CodeDefinition;
use JBBCode\ElementNode;
class YouTube extends CodeDefinition {
class YouTube extends CodeDefinition
{
public function __construct()
{
parent::__construct();
@ -21,13 +22,13 @@ class YouTube extends CodeDefinition {
{
$content = "";
foreach($el->getChildren() as $child) {
foreach ($el->getChildren() as $child) {
$content .= $child->getAsBBCode();
}
$foundMatch = preg_match('/^([A-z0-9=\-]+?)$/i', $content, $matches);
if(!$foundMatch) {
if (!$foundMatch) {
return $el->getAsBBCode();
} else {
return "<iframe width=\"640\" height=\"390\" src=\"https://www.youtube.com/embed/".$matches[1]."\" frameborder=\"0\" allowfullscreen></iframe>";