Conditions | 3 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
31 | public function loadTopic($topicPath) |
||
32 | { |
||
33 | $arguments = $this->urlMatcher->match('/'.$topicPath); |
||
34 | $topicFactory = $arguments['_topic_factory']; |
||
35 | |||
36 | if (!is_callable($topicFactory)) { |
||
37 | throw new LogicException("Topic $topicPath is not a callback."); |
||
38 | } |
||
39 | |||
40 | $topicInstance = $topicFactory($topicPath, $arguments); |
||
41 | |||
42 | if (!$topicInstance instanceof Topic) { |
||
43 | throw new LogicException(sprintf( |
||
44 | 'Topic callback for %s must return an instance of %s.', |
||
45 | $topicPath, |
||
46 | Topic::class |
||
47 | )); |
||
48 | } |
||
49 | |||
50 | return $topicInstance; |
||
51 | } |
||
52 | } |
||
53 |