I have 2 class:
namespace App\Http\Controllers;
class ConfigClass {
const ERROR_STATUS = 'kod html [[X]] error';
}
Second class:
use App\Http\Controllers\ConfigClass;
class StatusMessageClass
{
public function __construct()
{
$this->config = new ConfigClass();
}
public function createMessageWithStatus(string $messageType, string $description): array
{
$classValue = $this->config.'' . $messageType;
$html = str_replace("[[X]]", $description, $classValue);
$message = array(
'messageType' => $messageType,
'html' => $html,
'description' => $description
);
return $message;
}
}
And i use this code:
$val = $messageBox->createMessageWithStatus('ERROR_STATUS', "Błędny login lub hasło")
I have error in line (Object of class App\Http\Controllers\ConfigClass could not be converted to string)
$classValue = $this->config.'' . $messageType;
How can i repeir this?
I need this result: $classValue = $this->config::ERROR_STATUS; But I need get this value "ERROR_STATUS" from $messageType in function