1313namespace chillerlan \BBCode ;
1414
1515use chillerlan \BBCode \Output \BBCodeOutputInterface ;
16- use chillerlan \Traits \{
17- ClassLoader , ContainerInterface
18- };
16+ use chillerlan \Settings \SettingsContainerInterface ;
1917use Psr \Log \{
2018 LoggerAwareInterface , LoggerAwareTrait , LoggerInterface , NullLogger
2119};
2220use Psr \SimpleCache \CacheInterface ;
2321
2422class BBCode implements LoggerAwareInterface{
25- use ClassLoader, LoggerAwareTrait;
23+ use LoggerAwareTrait;
2624
2725 /**
28- * @var \chillerlan\BBCode\BBCodeOptions|\chillerlan\Traits\ContainerInterface
26+ * @var \chillerlan\BBCode\BBCodeOptions|\chillerlan\Settings\SettingsContainerInterface
2927 */
3028 protected $ options ;
3129
@@ -67,11 +65,11 @@ class BBCode implements LoggerAwareInterface{
6765 /**
6866 * BBCode constructor.
6967 *
70- * @param \chillerlan\Traits\ContainerInterface |null $options
71- * @param \Psr\SimpleCache\CacheInterface|null $cache
72- * @param \Psr\Log\LoggerInterface|null $logger
68+ * @param \chillerlan\Settings\SettingsContainerInterface |null $options
69+ * @param \Psr\SimpleCache\CacheInterface|null $cache
70+ * @param \Psr\Log\LoggerInterface|null $logger
7371 */
74- public function __construct (ContainerInterface $ options = null , CacheInterface $ cache = null , LoggerInterface $ logger = null ){
72+ public function __construct (SettingsContainerInterface $ options = null , CacheInterface $ cache = null , LoggerInterface $ logger = null ){
7573 $ this
7674 ->setCache ($ cache ?? new BBCache )
7775 ->setLogger ($ logger ?? new NullLogger );
@@ -112,12 +110,12 @@ public function setCache(CacheInterface $cache):BBCode{
112110 /**
113111 * @todo
114112 *
115- * @param \chillerlan\Traits\ContainerInterface $options
113+ * @param \chillerlan\Settings\SettingsContainerInterface $options
116114 *
117115 * @throws \chillerlan\BBCode\BBCodeException
118116 * @return \chillerlan\BBCode\BBCode
119117 */
120- public function setOptions (ContainerInterface $ options ):BBCode {
118+ public function setOptions (SettingsContainerInterface $ options ):BBCode {
121119 $ this ->options = $ options ;
122120
123121 mb_internal_encoding ('UTF-8 ' );
@@ -138,16 +136,28 @@ public function setOptions(ContainerInterface $options):BBCode{
138136 }
139137
140138 if ($ this ->options ->sanitizeInput || $ this ->options ->sanitizeOutput ){
141- $ this ->sanitizerInterface = $ this ->loadClass ($ this ->options ->sanitizerInterface , SanitizerInterface::class, $ this ->options );
139+ $ this ->sanitizerInterface = new $ this ->options ->sanitizerInterface ($ this ->options );
140+
141+ if (!$ this ->sanitizerInterface instanceof SanitizerInterface){
142+ throw new BBcodeException ('invalid SanitizerInterface ' );
143+ }
142144 }
143145
144146
145147
146148 if ($ this ->options ->preParse || $ this ->options ->postParse ){
147- $ this ->parserMiddleware = $ this ->loadClass ($ this ->options ->parserMiddlewareInterface , ParserMiddlewareInterface::class, $ this ->options , $ this ->cache , $ this ->logger );
149+ $ this ->parserMiddleware = new $ this ->options ->parserMiddlewareInterface ($ this ->options , $ this ->cache , $ this ->logger );
150+
151+ if (!$ this ->parserMiddleware instanceof ParserMiddlewareInterface){
152+ throw new BBcodeException ('invalid ParserMiddlewareInterface ' );
153+ }
148154 }
149155
150- $ this ->outputInterface = $ this ->loadClass ($ this ->options ->outputInterface , BBCodeOutputInterface::class, $ this ->options , $ this ->cache , $ this ->logger );
156+ $ this ->outputInterface = new $ this ->options ->outputInterface ($ this ->options , $ this ->cache , $ this ->logger );
157+
158+ if (!$ this ->outputInterface instanceof BBCodeOutputInterface){
159+ throw new BBcodeException ('invalid BBCodeOutputInterface ' );
160+ }
151161
152162 $ this ->tags = $ this ->outputInterface ->getTags ();
153163 $ this ->noparse = $ this ->outputInterface ->getNoparse ();
0 commit comments