Merge pull request #6 from flashwave/analysis-XZ7k6q
Applied fixes from StyleCI
This commit is contained in:
commit
bf44b6b807
6 changed files with 25 additions and 15 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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>';
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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>";
|
||||
|
|
Reference in a new issue