Refactor command inclusion logic in getText and getCaption
This commit is contained in:
parent
b826d0d4dd
commit
12a091ce80
1 changed files with 11 additions and 11 deletions
|
@ -341,18 +341,18 @@
|
||||||
* @param bool $includeCommand
|
* @param bool $includeCommand
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public function getText(bool $includeCommand=true): ?string
|
public function getText(bool $includeCommand=false): ?string
|
||||||
{
|
{
|
||||||
if($includeCommand)
|
|
||||||
{
|
|
||||||
return $this->text;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->text === null)
|
if($this->text === null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($includeCommand)
|
||||||
|
{
|
||||||
|
return $this->text;
|
||||||
|
}
|
||||||
|
|
||||||
if(preg_match('/^\/([a-zA-Z0-9_]+)(?:@[a-zA-Z0-9_]+)?/', $this->text, $matches))
|
if(preg_match('/^\/([a-zA-Z0-9_]+)(?:@[a-zA-Z0-9_]+)?/', $this->text, $matches))
|
||||||
{
|
{
|
||||||
return str_replace($matches[0], '', $this->text);
|
return str_replace($matches[0], '', $this->text);
|
||||||
|
@ -502,16 +502,16 @@
|
||||||
*/
|
*/
|
||||||
public function getCaption(bool $includeCommand=false): ?string
|
public function getCaption(bool $includeCommand=false): ?string
|
||||||
{
|
{
|
||||||
if($includeCommand)
|
|
||||||
{
|
|
||||||
return $this->caption;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->caption === null)
|
if($this->caption === null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($includeCommand)
|
||||||
|
{
|
||||||
|
return $this->caption;
|
||||||
|
}
|
||||||
|
|
||||||
if(preg_match('/^\/([a-zA-Z0-9_]+)(?:@[a-zA-Z0-9_]+)?/', $this->caption, $matches))
|
if(preg_match('/^\/([a-zA-Z0-9_]+)(?:@[a-zA-Z0-9_]+)?/', $this->caption, $matches))
|
||||||
{
|
{
|
||||||
return str_replace($matches[0], '', $this->caption);
|
return str_replace($matches[0], '', $this->caption);
|
||||||
|
|
Loading…
Add table
Reference in a new issue