Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 148 Revision 991
Zeile 11... Zeile 11...
11
 * file that was distributed with this source code.
11
 * file that was distributed with this source code.
12
 */
12
 */
Zeile 13... Zeile 13...
13
 
13
 
Zeile -... Zeile 14...
-
 
14
namespace League\CommonMark\Extension\Mention\Generator;
14
namespace League\CommonMark\Extension\Mention\Generator;
15
 
15
 
16
use League\CommonMark\Exception\LogicException;
Zeile 16... Zeile 17...
16
use League\CommonMark\Extension\Mention\Mention;
17
use League\CommonMark\Extension\Mention\Mention;
17
use League\CommonMark\Node\Inline\AbstractInline;
18
use League\CommonMark\Node\Inline\AbstractInline;
Zeile 28... Zeile 29...
28
    public function __construct(callable $callback)
29
    public function __construct(callable $callback)
29
    {
30
    {
30
        $this->callback = $callback;
31
        $this->callback = $callback;
31
    }
32
    }
Zeile -... Zeile 33...
-
 
33
 
-
 
34
    /**
-
 
35
     * @throws LogicException
32
 
36
     */
33
    public function generateMention(Mention $mention): ?AbstractInline
37
    public function generateMention(Mention $mention): ?AbstractInline
34
    {
38
    {
35
        $result = \call_user_func($this->callback, $mention);
39
        $result = \call_user_func($this->callback, $mention);
36
        if ($result === null) {
40
        if ($result === null) {
Zeile 43... Zeile 47...
43
 
47
 
44
        if ($result instanceof Mention && $result->hasUrl()) {
48
        if ($result instanceof Mention && $result->hasUrl()) {
45
            return $mention;
49
            return $mention;
Zeile 46... Zeile 50...
46
        }
50
        }
47
 
51
 
48
        throw new \RuntimeException('CallbackGenerator callable must set the URL on the passed mention and return the mention, return a new AbstractInline based object or null if the mention is not a match');
52
        throw new LogicException('CallbackGenerator callable must set the URL on the passed mention and return the mention, return a new AbstractInline based object or null if the mention is not a match');