blob: 277f86ea90e8833cec8685f739824a32a734a6d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<?php
namespace SMW\Parser;
/**
* @license GNU GPL v2+
* @since 2.5
*
* @author mwjames
*/
class SemanticLinksParser {
/**
* @var LinksProcessor
*/
private $linksProcessor;
/**
* @since 2.5
*
* @param LinksProcessor $linksProcessor
*/
public function __construct( LinksProcessor $linksProcessor ) {
$this->linksProcessor = $linksProcessor;
}
/**
* @since 2.5
*
* @param $text
*
* @return array
*/
public function parse( $text ) {
$matches = [];
preg_match(
$this->linksProcessor->getRegexpPattern(),
$text,
$matches
);
if ( $matches === [] ) {
return [];
}
$semanticLinks = $this->linksProcessor->preprocess( $matches );
if ( is_string( $semanticLinks ) ) {
return [];
}
$semanticLinks = $this->linksProcessor->process( $semanticLinks );
if ( is_string( $semanticLinks ) ) {
return [];
}
return $semanticLinks;
}
}
|