Skip to content

Commit

Permalink
Made it cwork with old PHP versions again
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskonnertz committed Jan 24, 2018
1 parent 91068a7 commit 7a64a33
Showing 1 changed file with 33 additions and 27 deletions.
60 changes: 33 additions & 27 deletions src/ChrisKonnertz/BBCode/BBCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class BBCode
{

/**
* Constants with the names of the built-in tags
* Constants with the names of the built-in default tags
* Call getDefaultTagNames() to get them as an array.
*/
const TAG_NAME_B = 'b';
const TAG_NAME_I = 'i';
Expand All @@ -39,32 +40,6 @@ class BBCode
const TAG_NAME_RIGHT = 'right';
const TAG_NAME_SPOILER = 'spoiler';

/**
* Array with the names of all tags
*/
const TAG_NAMES = [
self::TAG_NAME_B,
self::TAG_NAME_I,
self::TAG_NAME_S,
self::TAG_NAME_U,
self::TAG_NAME_CODE,
self::TAG_NAME_EMAIL,
self::TAG_NAME_URL,
self::TAG_NAME_IMG,
self::TAG_NAME_LIST,
self::TAG_NAME_LI_STAR,
self::TAG_NAME_LI,
self::TAG_NAME_QUOTE,
self::TAG_NAME_YOUTUBE,
self::TAG_NAME_FONT,
self::TAG_NAME_SIZE,
self::TAG_NAME_COLOR,
self::TAG_NAME_LEFT,
self::TAG_NAME_CENTER,
self::TAG_NAME_RIGHT,
self::TAG_NAME_SPOILER,
];

/**
* The text with BBCodes
*
Expand Down Expand Up @@ -644,6 +619,37 @@ public function setYouTubeHeight($youTubeHeight)
$this->youTubeHeight = $youTubeHeight;
}

/**
* Returns an array with the names of all default tags
*
* @return string[]
*/
public function getDefaultTagNames()
{
return [
self::TAG_NAME_B,
self::TAG_NAME_I,
self::TAG_NAME_S,
self::TAG_NAME_U,
self::TAG_NAME_CODE,
self::TAG_NAME_EMAIL,
self::TAG_NAME_URL,
self::TAG_NAME_IMG,
self::TAG_NAME_LIST,
self::TAG_NAME_LI_STAR,
self::TAG_NAME_LI,
self::TAG_NAME_QUOTE,
self::TAG_NAME_YOUTUBE,
self::TAG_NAME_FONT,
self::TAG_NAME_SIZE,
self::TAG_NAME_COLOR,
self::TAG_NAME_LEFT,
self::TAG_NAME_CENTER,
self::TAG_NAME_RIGHT,
self::TAG_NAME_SPOILER,
];
}

/**
* Returns true if $haystack ends with $needle
*
Expand Down

0 comments on commit 7a64a33

Please sign in to comment.