@@ -14,87 +14,87 @@ |
||
14 | 14 | class QueryModifierBuilderTest extends \PHPUnit_Framework_TestCase { |
15 | 15 | |
16 | 16 | public function testGroupByModifier() { |
17 | - $queryBuilder = new QueryModifierBuilder( new UsageValidator() ); |
|
18 | - $queryBuilder->groupBy( array( '?test' ) ); |
|
17 | + $queryBuilder = new QueryModifierBuilder(new UsageValidator()); |
|
18 | + $queryBuilder->groupBy(array('?test')); |
|
19 | 19 | |
20 | - $this->assertEquals( ' GROUP BY ?test', $queryBuilder->getSPARQL() ); |
|
20 | + $this->assertEquals(' GROUP BY ?test', $queryBuilder->getSPARQL()); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function testGroupByModifier_invalidArgument() { |
24 | - $queryBuilder = new QueryModifierBuilder( new UsageValidator() ); |
|
25 | - $this->setExpectedException( 'InvalidArgumentException' ); |
|
24 | + $queryBuilder = new QueryModifierBuilder(new UsageValidator()); |
|
25 | + $this->setExpectedException('InvalidArgumentException'); |
|
26 | 26 | |
27 | - $queryBuilder->groupBy( array( null ) ); |
|
27 | + $queryBuilder->groupBy(array(null)); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function testHavingModifier() { |
31 | - $queryBuilder = new QueryModifierBuilder( new UsageValidator() ); |
|
32 | - $queryBuilder->having( '?test' ); |
|
31 | + $queryBuilder = new QueryModifierBuilder(new UsageValidator()); |
|
32 | + $queryBuilder->having('?test'); |
|
33 | 33 | |
34 | - $this->assertEquals( ' HAVING (?test)', $queryBuilder->getSPARQL() ); |
|
34 | + $this->assertEquals(' HAVING (?test)', $queryBuilder->getSPARQL()); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function testHavingModifier_invalidArgument() { |
38 | - $queryBuilder = new QueryModifierBuilder( new UsageValidator() ); |
|
39 | - $this->setExpectedException( 'InvalidArgumentException' ); |
|
38 | + $queryBuilder = new QueryModifierBuilder(new UsageValidator()); |
|
39 | + $this->setExpectedException('InvalidArgumentException'); |
|
40 | 40 | |
41 | - $queryBuilder->having( null ); |
|
41 | + $queryBuilder->having(null); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | public function testOrderByModifier() { |
45 | - $queryBuilder = new QueryModifierBuilder( new UsageValidator() ); |
|
46 | - $queryBuilder->orderBy( '?test' ); |
|
45 | + $queryBuilder = new QueryModifierBuilder(new UsageValidator()); |
|
46 | + $queryBuilder->orderBy('?test'); |
|
47 | 47 | |
48 | - $this->assertEquals( ' ORDER BY ASC (?test)', $queryBuilder->getSPARQL() ); |
|
48 | + $this->assertEquals(' ORDER BY ASC (?test)', $queryBuilder->getSPARQL()); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | public function testOrderByDescModifier() { |
52 | - $queryBuilder = new QueryModifierBuilder( new UsageValidator() ); |
|
53 | - $queryBuilder->orderBy( '?test', 'DESC' ); |
|
52 | + $queryBuilder = new QueryModifierBuilder(new UsageValidator()); |
|
53 | + $queryBuilder->orderBy('?test', 'DESC'); |
|
54 | 54 | |
55 | - $this->assertEquals( ' ORDER BY DESC (?test)', $queryBuilder->getSPARQL() ); |
|
55 | + $this->assertEquals(' ORDER BY DESC (?test)', $queryBuilder->getSPARQL()); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | public function testOrderByModifier_invalidArgument() { |
59 | - $queryBuilder = new QueryModifierBuilder( new UsageValidator() ); |
|
60 | - $this->setExpectedException( 'InvalidArgumentException' ); |
|
59 | + $queryBuilder = new QueryModifierBuilder(new UsageValidator()); |
|
60 | + $this->setExpectedException('InvalidArgumentException'); |
|
61 | 61 | |
62 | - $queryBuilder->orderBy( null ); |
|
62 | + $queryBuilder->orderBy(null); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | public function testOrderByModifier_invalidDirection() { |
66 | - $queryBuilder = new QueryModifierBuilder( new UsageValidator() ); |
|
67 | - $this->setExpectedException( 'InvalidArgumentException' ); |
|
66 | + $queryBuilder = new QueryModifierBuilder(new UsageValidator()); |
|
67 | + $this->setExpectedException('InvalidArgumentException'); |
|
68 | 68 | |
69 | - $queryBuilder->orderBy( '?test', 'FOO' ); |
|
69 | + $queryBuilder->orderBy('?test', 'FOO'); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | public function testLimitModifier() { |
73 | - $queryBuilder = new QueryModifierBuilder( new UsageValidator() ); |
|
74 | - $queryBuilder->limit( 42 ); |
|
73 | + $queryBuilder = new QueryModifierBuilder(new UsageValidator()); |
|
74 | + $queryBuilder->limit(42); |
|
75 | 75 | |
76 | - $this->assertEquals( ' LIMIT 42', $queryBuilder->getSPARQL() ); |
|
76 | + $this->assertEquals(' LIMIT 42', $queryBuilder->getSPARQL()); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | public function testLimitModifier_invalidArgument() { |
80 | - $queryBuilder = new QueryModifierBuilder( new UsageValidator() ); |
|
81 | - $this->setExpectedException( 'InvalidArgumentException' ); |
|
80 | + $queryBuilder = new QueryModifierBuilder(new UsageValidator()); |
|
81 | + $this->setExpectedException('InvalidArgumentException'); |
|
82 | 82 | |
83 | - $queryBuilder->limit( null ); |
|
83 | + $queryBuilder->limit(null); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | public function testOffsetModifier() { |
87 | - $queryBuilder = new QueryModifierBuilder( new UsageValidator() ); |
|
88 | - $queryBuilder->offset( 42 ); |
|
87 | + $queryBuilder = new QueryModifierBuilder(new UsageValidator()); |
|
88 | + $queryBuilder->offset(42); |
|
89 | 89 | |
90 | - $this->assertEquals( ' OFFSET 42', $queryBuilder->getSPARQL() ); |
|
90 | + $this->assertEquals(' OFFSET 42', $queryBuilder->getSPARQL()); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | public function testOffsetModifier_invalidArgument() { |
94 | - $queryBuilder = new QueryModifierBuilder( new UsageValidator() ); |
|
95 | - $this->setExpectedException( 'InvalidArgumentException' ); |
|
94 | + $queryBuilder = new QueryModifierBuilder(new UsageValidator()); |
|
95 | + $this->setExpectedException('InvalidArgumentException'); |
|
96 | 96 | |
97 | - $queryBuilder->offset( null ); |
|
97 | + $queryBuilder->offset(null); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | } |
@@ -15,20 +15,20 @@ |
||
15 | 15 | /** |
16 | 16 | * @dataProvider provideTestFormat |
17 | 17 | */ |
18 | - public function testFormat( $expected, $input ) { |
|
18 | + public function testFormat($expected, $input) { |
|
19 | 19 | $formatter = new QueryFormatter(); |
20 | 20 | |
21 | - $this->assertEquals( $expected, $formatter->format( $input ) ); |
|
21 | + $this->assertEquals($expected, $formatter->format($input)); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function provideTestFormat() { |
25 | 25 | return array( |
26 | - 'new line before prefix' => array( "PREFIX abc\nPREFIX\n", 'PREFIX abc PREFIX' ), |
|
27 | - 'new lines before select' => array( "foobar\n\nSELECT xyz\n", 'foobar SELECT xyz' ), |
|
28 | - 'new line after brackets' => array( "abc {\n}\ndef\n", 'abc { } def' ), |
|
29 | - 'indentation by brackets' => array( "{\n\t{\n\t\tfoobar .\n\t}\n\tnyan .\n}\n", '{ { foobar . } nyan . }' ), |
|
30 | - 'strings get escaped' => array( '"abc { def } hij" <abc { xyy > <"a{2>' . "\n", '"abc { def } hij" <abc { xyy > <"a{2>' ), |
|
31 | - 'spaces before characters' => array( "a .\nb =c (d <e {\n\tf ?g \$h\n", 'a.b=c(d<e{f?g$h' ) |
|
26 | + 'new line before prefix' => array("PREFIX abc\nPREFIX\n", 'PREFIX abc PREFIX'), |
|
27 | + 'new lines before select' => array("foobar\n\nSELECT xyz\n", 'foobar SELECT xyz'), |
|
28 | + 'new line after brackets' => array("abc {\n}\ndef\n", 'abc { } def'), |
|
29 | + 'indentation by brackets' => array("{\n\t{\n\t\tfoobar .\n\t}\n\tnyan .\n}\n", '{ { foobar . } nyan . }'), |
|
30 | + 'strings get escaped' => array('"abc { def } hij" <abc { xyy > <"a{2>' . "\n", '"abc { def } hij" <abc { xyy > <"a{2>'), |
|
31 | + 'spaces before characters' => array("a .\nb =c (d <e {\n\tf ?g \$h\n", 'a.b=c(d<e{f?g$h') |
|
32 | 32 | ); |
33 | 33 | } |
34 | 34 |
@@ -20,15 +20,15 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * @param string $userAgent |
22 | 22 | */ |
23 | - public function __construct( $userAgent ) { |
|
23 | + public function __construct($userAgent) { |
|
24 | 24 | $this->ch = curl_init(); |
25 | - curl_setopt( $this->ch, CURLOPT_USERAGENT, $userAgent ); |
|
26 | - curl_setopt( $this->ch, CURLOPT_RETURNTRANSFER, true ); |
|
27 | - curl_setopt( $this->ch, CURLOPT_FOLLOWLOCATION, true ); |
|
25 | + curl_setopt($this->ch, CURLOPT_USERAGENT, $userAgent); |
|
26 | + curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); |
|
27 | + curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function __destruct() { |
31 | - curl_close( $this->ch ); |
|
31 | + curl_close($this->ch); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -37,16 +37,16 @@ discard block |
||
37 | 37 | * @return string |
38 | 38 | * @throws RuntimeException |
39 | 39 | */ |
40 | - public function request( $url, array $params = array() ) { |
|
41 | - curl_setopt( $this->ch, CURLOPT_URL, $url . '?' . http_build_query( $params ) ); |
|
42 | - curl_setopt( $this->ch, CURLOPT_HTTPGET, true ); |
|
40 | + public function request($url, array $params = array()) { |
|
41 | + curl_setopt($this->ch, CURLOPT_URL, $url . '?' . http_build_query($params)); |
|
42 | + curl_setopt($this->ch, CURLOPT_HTTPGET, true); |
|
43 | 43 | |
44 | - $response = curl_exec( $this->ch ); |
|
44 | + $response = curl_exec($this->ch); |
|
45 | 45 | |
46 | - if ( curl_errno( $this->ch ) ) { |
|
47 | - throw new RuntimeException( curl_error( $this->ch ), curl_errno( $this->ch ) ); |
|
48 | - } else if ( curl_getinfo( $this->ch, CURLINFO_HTTP_CODE ) >= 400 ) { |
|
49 | - throw new RuntimeException( 'HTTP error: ' . $url, curl_getinfo( $this->ch, CURLINFO_HTTP_CODE ) ); |
|
46 | + if (curl_errno($this->ch)) { |
|
47 | + throw new RuntimeException(curl_error($this->ch), curl_errno($this->ch)); |
|
48 | + } else if (curl_getinfo($this->ch, CURLINFO_HTTP_CODE) >= 400) { |
|
49 | + throw new RuntimeException('HTTP error: ' . $url, curl_getinfo($this->ch, CURLINFO_HTTP_CODE)); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | return $response; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | private $usageValidator; |
29 | 29 | |
30 | - public function __construct( UsageValidator $usageValidator ) { |
|
30 | + public function __construct(UsageValidator $usageValidator) { |
|
31 | 31 | $this->expressionValidator = new ExpressionValidator(); |
32 | 32 | $this->usageValidator = $usageValidator; |
33 | 33 | } |
@@ -37,16 +37,16 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @param string[] $expressions |
39 | 39 | */ |
40 | - public function groupBy( array $expressions ) { |
|
41 | - foreach ( $expressions as $expression ) { |
|
42 | - $this->expressionValidator->validate( $expression, |
|
40 | + public function groupBy(array $expressions) { |
|
41 | + foreach ($expressions as $expression) { |
|
42 | + $this->expressionValidator->validate($expression, |
|
43 | 43 | ExpressionValidator::VALIDATE_VARIABLE | ExpressionValidator::VALIDATE_FUNCTION_AS |
44 | 44 | ); |
45 | 45 | } |
46 | 46 | |
47 | - $expression = implode( ' ', $expressions ); |
|
48 | - $this->usageValidator->trackUsedPrefixes( $expression ); |
|
49 | - $this->usageValidator->trackUsedVariables( $expression ); |
|
47 | + $expression = implode(' ', $expressions); |
|
48 | + $this->usageValidator->trackUsedPrefixes($expression); |
|
49 | + $this->usageValidator->trackUsedVariables($expression); |
|
50 | 50 | $this->modifiers['GROUP BY'] = $expression; |
51 | 51 | } |
52 | 52 | |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @param string $expression |
57 | 57 | */ |
58 | - public function having( $expression ) { |
|
59 | - $this->expressionValidator->validate( $expression, ExpressionValidator::VALIDATE_FUNCTION ); |
|
58 | + public function having($expression) { |
|
59 | + $this->expressionValidator->validate($expression, ExpressionValidator::VALIDATE_FUNCTION); |
|
60 | 60 | |
61 | - $this->usageValidator->trackUsedPrefixes( $expression ); |
|
62 | - $this->usageValidator->trackUsedVariables( $expression ); |
|
61 | + $this->usageValidator->trackUsedPrefixes($expression); |
|
62 | + $this->usageValidator->trackUsedVariables($expression); |
|
63 | 63 | $this->modifiers['HAVING'] = '(' . $expression . ')'; |
64 | 64 | } |
65 | 65 | |
@@ -70,18 +70,18 @@ discard block |
||
70 | 70 | * @param string $direction one of ASC or DESC |
71 | 71 | * @throws InvalidArgumentException |
72 | 72 | */ |
73 | - public function orderBy( $expression, $direction = 'ASC' ) { |
|
74 | - $direction = strtoupper( $direction ); |
|
75 | - if ( !in_array( $direction, array( 'ASC', 'DESC' ) ) ) { |
|
76 | - throw new InvalidArgumentException( '$direction has to be either ASC or DESC' ); |
|
73 | + public function orderBy($expression, $direction = 'ASC') { |
|
74 | + $direction = strtoupper($direction); |
|
75 | + if (!in_array($direction, array('ASC', 'DESC'))) { |
|
76 | + throw new InvalidArgumentException('$direction has to be either ASC or DESC'); |
|
77 | 77 | } |
78 | 78 | |
79 | - $this->expressionValidator->validate( $expression, |
|
79 | + $this->expressionValidator->validate($expression, |
|
80 | 80 | ExpressionValidator::VALIDATE_VARIABLE | ExpressionValidator::VALIDATE_FUNCTION |
81 | 81 | ); |
82 | 82 | |
83 | - $this->usageValidator->trackUsedPrefixes( $expression ); |
|
84 | - $this->usageValidator->trackUsedVariables( $expression ); |
|
83 | + $this->usageValidator->trackUsedPrefixes($expression); |
|
84 | + $this->usageValidator->trackUsedVariables($expression); |
|
85 | 85 | $this->modifiers['ORDER BY'] = $direction . ' (' . $expression . ')'; |
86 | 86 | } |
87 | 87 | |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | * @param int $limit |
92 | 92 | * @throws InvalidArgumentException |
93 | 93 | */ |
94 | - public function limit( $limit ) { |
|
95 | - if ( !is_int( $limit ) ) { |
|
96 | - throw new InvalidArgumentException( '$limit has to be an integer' ); |
|
94 | + public function limit($limit) { |
|
95 | + if (!is_int($limit)) { |
|
96 | + throw new InvalidArgumentException('$limit has to be an integer'); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | $this->modifiers['LIMIT'] = $limit; |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * @param int $offset |
106 | 106 | * @throws InvalidArgumentException |
107 | 107 | */ |
108 | - public function offset( $offset ) { |
|
109 | - if ( !is_int( $offset ) ) { |
|
110 | - throw new InvalidArgumentException( '$offset has to be an integer' ); |
|
108 | + public function offset($offset) { |
|
109 | + if (!is_int($offset)) { |
|
110 | + throw new InvalidArgumentException('$offset has to be an integer'); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | $this->modifiers['OFFSET'] = $offset; |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function getSPARQL() { |
122 | 122 | $modifiers = $this->modifiers; |
123 | - return implode( array_map( function( $key ) use ( $modifiers ) { |
|
124 | - if ( isset( $modifiers[$key] ) ) { |
|
123 | + return implode(array_map(function($key) use ($modifiers) { |
|
124 | + if (isset($modifiers[$key])) { |
|
125 | 125 | return ' ' . $key . ' ' . $modifiers[$key]; |
126 | 126 | } |
127 | - }, array( 'GROUP BY', 'HAVING', 'ORDER BY', 'LIMIT', 'OFFSET' ) ) ); |
|
127 | + }, array('GROUP BY', 'HAVING', 'ORDER BY', 'LIMIT', 'OFFSET'))); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | } |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @param string[] $prefixes |
32 | 32 | */ |
33 | - public function __construct( array $prefixes, UsageValidator $usageValidator ) { |
|
33 | + public function __construct(array $prefixes, UsageValidator $usageValidator) { |
|
34 | 34 | $this->expressionValidator = new ExpressionValidator(); |
35 | 35 | $this->usageValidator = $usageValidator; |
36 | - $this->setPrefixes( $prefixes ); |
|
36 | + $this->setPrefixes($prefixes); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -42,15 +42,15 @@ discard block |
||
42 | 42 | * @param string[] $prefixes |
43 | 43 | * @throws InvalidArgumentException |
44 | 44 | */ |
45 | - private function setPrefixes( array $prefixes ) { |
|
46 | - foreach ( $prefixes as $prefix => $iri ) { |
|
47 | - $this->expressionValidator->validate( $prefix, ExpressionValidator::VALIDATE_PREFIX ); |
|
48 | - $this->expressionValidator->validate( $iri, ExpressionValidator::VALIDATE_IRI ); |
|
45 | + private function setPrefixes(array $prefixes) { |
|
46 | + foreach ($prefixes as $prefix => $iri) { |
|
47 | + $this->expressionValidator->validate($prefix, ExpressionValidator::VALIDATE_PREFIX); |
|
48 | + $this->expressionValidator->validate($iri, ExpressionValidator::VALIDATE_IRI); |
|
49 | 49 | |
50 | 50 | $this->prefixes[$prefix] = $iri; |
51 | 51 | } |
52 | 52 | |
53 | - $this->usageValidator->trackDefinedPrefixes( array_keys( $this->prefixes ) ); |
|
53 | + $this->usageValidator->trackDefinedPrefixes(array_keys($this->prefixes)); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * @return string |
67 | 67 | */ |
68 | 68 | public function getSPARQL() { |
69 | - return implode( array_map( function( $prefix, $iri ) { |
|
69 | + return implode(array_map(function($prefix, $iri) { |
|
70 | 70 | return 'PREFIX ' . $prefix . ': <' . $iri . '> '; |
71 | - }, array_keys( $this->prefixes ), $this->prefixes ) ); |
|
71 | + }, array_keys($this->prefixes), $this->prefixes)); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | } |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | * @var string[] $prefixes |
64 | 64 | * @throws InvalidArgumentException |
65 | 65 | */ |
66 | - public function __construct( array $prefixes = array() ) { |
|
66 | + public function __construct(array $prefixes = array()) { |
|
67 | 67 | $this->expressionValidator = new ExpressionValidator(); |
68 | 68 | $this->usageValidator = new UsageValidator(); |
69 | - $this->prefixBuilder = new QueryPrefixBuilder( $prefixes, $this->usageValidator ); |
|
70 | - $this->graphBuilder = new GraphBuilder( $this->usageValidator ); |
|
71 | - $this->modifierBuilder = new QueryModifierBuilder( $this->usageValidator ); |
|
69 | + $this->prefixBuilder = new QueryPrefixBuilder($prefixes, $this->usageValidator); |
|
70 | + $this->graphBuilder = new GraphBuilder($this->usageValidator); |
|
71 | + $this->modifierBuilder = new QueryModifierBuilder($this->usageValidator); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | * @throws InvalidArgumentException |
89 | 89 | * @throws RuntimeException |
90 | 90 | */ |
91 | - public function select( $expressions /* expressions ... */ ) { |
|
92 | - $expressions = is_array( $expressions ) ? $expressions : func_get_args(); |
|
91 | + public function select($expressions /* expressions ... */) { |
|
92 | + $expressions = is_array($expressions) ? $expressions : func_get_args(); |
|
93 | 93 | |
94 | - $this->setQueryForm( 'SELECT' ); |
|
95 | - $this->addExpressions( $expressions ); |
|
94 | + $this->setQueryForm('SELECT'); |
|
95 | + $this->addExpressions($expressions); |
|
96 | 96 | |
97 | 97 | return $this; |
98 | 98 | } |
@@ -107,12 +107,12 @@ discard block |
||
107 | 107 | * @throws InvalidArgumentException |
108 | 108 | * @throws RuntimeException |
109 | 109 | */ |
110 | - public function selectDistinct( $expressions /* expressions ... */ ) { |
|
111 | - $expressions = is_array( $expressions ) ? $expressions : func_get_args(); |
|
110 | + public function selectDistinct($expressions /* expressions ... */) { |
|
111 | + $expressions = is_array($expressions) ? $expressions : func_get_args(); |
|
112 | 112 | |
113 | - $this->setQueryForm( 'SELECT' ); |
|
113 | + $this->setQueryForm('SELECT'); |
|
114 | 114 | $this->uniqueness = 'DISTINCT '; |
115 | - $this->addExpressions( $expressions ); |
|
115 | + $this->addExpressions($expressions); |
|
116 | 116 | |
117 | 117 | return $this; |
118 | 118 | } |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | * @throws InvalidArgumentException |
128 | 128 | * @throws RuntimeException |
129 | 129 | */ |
130 | - public function selectReduced( $expressions /* expressions ... */ ) { |
|
131 | - $expressions = is_array( $expressions ) ? $expressions : func_get_args(); |
|
130 | + public function selectReduced($expressions /* expressions ... */) { |
|
131 | + $expressions = is_array($expressions) ? $expressions : func_get_args(); |
|
132 | 132 | |
133 | - $this->setQueryForm( 'SELECT' ); |
|
133 | + $this->setQueryForm('SELECT'); |
|
134 | 134 | $this->uniqueness = 'REDUCED '; |
135 | - $this->addExpressions( $expressions ); |
|
135 | + $this->addExpressions($expressions); |
|
136 | 136 | |
137 | 137 | return $this; |
138 | 138 | } |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | * @throws InvalidArgumentException |
148 | 148 | * @throws RuntimeException |
149 | 149 | */ |
150 | - public function describe( $expressions /* expressions ... */ ) { |
|
151 | - $expressions = is_array( $expressions ) ? $expressions : func_get_args(); |
|
150 | + public function describe($expressions /* expressions ... */) { |
|
151 | + $expressions = is_array($expressions) ? $expressions : func_get_args(); |
|
152 | 152 | |
153 | - $this->setQueryForm( 'DESCRIBE' ); |
|
153 | + $this->setQueryForm('DESCRIBE'); |
|
154 | 154 | $this->addExpressions( |
155 | 155 | $expressions, |
156 | 156 | ExpressionValidator::VALIDATE_VARIABLE | ExpressionValidator::VALIDATE_FUNCTION_AS |
@@ -160,16 +160,16 @@ discard block |
||
160 | 160 | return $this; |
161 | 161 | } |
162 | 162 | |
163 | - private function setQueryForm( $queryForm ) { |
|
164 | - if ( $this->queryForm !== null ) { |
|
165 | - throw new RuntimeException( 'Query type is already set to ' . $this->queryForm ); |
|
163 | + private function setQueryForm($queryForm) { |
|
164 | + if ($this->queryForm !== null) { |
|
165 | + throw new RuntimeException('Query type is already set to ' . $this->queryForm); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | $this->queryForm = $queryForm; |
169 | 169 | } |
170 | 170 | |
171 | - private function addExpressions( array $expressions, $options = null ) { |
|
172 | - foreach ( $expressions as $expression ) { |
|
171 | + private function addExpressions(array $expressions, $options = null) { |
|
172 | + foreach ($expressions as $expression) { |
|
173 | 173 | $this->expressionValidator->validate( |
174 | 174 | $expression, |
175 | 175 | $options ?: ExpressionValidator::VALIDATE_VARIABLE | ExpressionValidator::VALIDATE_FUNCTION_AS |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | |
178 | 178 | // @todo temp hack to add AS definitions to defined variables |
179 | 179 | $regexHelper = new RegexHelper(); |
180 | - $matches = $regexHelper->getMatches( 'AS \{variable}', $expression ); |
|
181 | - $this->usageValidator->trackDefinedVariables( $matches ); |
|
180 | + $matches = $regexHelper->getMatches('AS \{variable}', $expression); |
|
181 | + $this->usageValidator->trackDefinedVariables($matches); |
|
182 | 182 | |
183 | 183 | // @todo detect functions and wrap with brackets automatically |
184 | - $this->usageValidator->trackUsedVariables( $expression ); |
|
185 | - $this->usageValidator->trackUsedPrefixes( $expression ); |
|
184 | + $this->usageValidator->trackUsedVariables($expression); |
|
185 | + $this->usageValidator->trackUsedPrefixes($expression); |
|
186 | 186 | $this->selects[] = $expression; |
187 | 187 | } |
188 | 188 | } |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | * @return self |
197 | 197 | * @throws InvalidArgumentException |
198 | 198 | */ |
199 | - public function where( $subject, $predicate, $object ) { |
|
200 | - $this->graphBuilder->where( $subject, $predicate, $object ); |
|
199 | + public function where($subject, $predicate, $object) { |
|
200 | + $this->graphBuilder->where($subject, $predicate, $object); |
|
201 | 201 | return $this; |
202 | 202 | } |
203 | 203 | |
@@ -211,8 +211,8 @@ discard block |
||
211 | 211 | * @return self |
212 | 212 | * @throws InvalidArgumentException |
213 | 213 | */ |
214 | - public function also( $subject, $predicate = null, $object = null ) { |
|
215 | - $this->graphBuilder->also( $subject, $predicate, $object ); |
|
214 | + public function also($subject, $predicate = null, $object = null) { |
|
215 | + $this->graphBuilder->also($subject, $predicate, $object); |
|
216 | 216 | return $this; |
217 | 217 | } |
218 | 218 | |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | * @return self |
228 | 228 | * @throws InvalidArgumentException |
229 | 229 | */ |
230 | - public function optional( $subject, $predicate = null, $object = null ) { |
|
231 | - $this->graphBuilder->optional( $subject, $predicate, $object ); |
|
230 | + public function optional($subject, $predicate = null, $object = null) { |
|
231 | + $this->graphBuilder->optional($subject, $predicate, $object); |
|
232 | 232 | return $this; |
233 | 233 | } |
234 | 234 | |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | * @return self |
242 | 242 | * @throws InvalidArgumentException |
243 | 243 | */ |
244 | - public function filter( $expression ) { |
|
245 | - $this->graphBuilder->filter( $expression ); |
|
244 | + public function filter($expression) { |
|
245 | + $this->graphBuilder->filter($expression); |
|
246 | 246 | return $this; |
247 | 247 | } |
248 | 248 | |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | * @return self |
258 | 258 | * @throws InvalidArgumentException |
259 | 259 | */ |
260 | - public function filterExists( $subject, $predicate = null, $object = null ) { |
|
261 | - $this->graphBuilder->filterExists( $subject, $predicate, $object ); |
|
260 | + public function filterExists($subject, $predicate = null, $object = null) { |
|
261 | + $this->graphBuilder->filterExists($subject, $predicate, $object); |
|
262 | 262 | return $this; |
263 | 263 | } |
264 | 264 | |
@@ -273,8 +273,8 @@ discard block |
||
273 | 273 | * @return self |
274 | 274 | * @throws InvalidArgumentException |
275 | 275 | */ |
276 | - public function filterNotExists( $subject, $predicate = null, $object = null ) { |
|
277 | - $this->graphBuilder->filterNotExists( $subject, $predicate, $object ); |
|
276 | + public function filterNotExists($subject, $predicate = null, $object = null) { |
|
277 | + $this->graphBuilder->filterNotExists($subject, $predicate, $object); |
|
278 | 278 | return $this; |
279 | 279 | } |
280 | 280 | |
@@ -287,8 +287,8 @@ discard block |
||
287 | 287 | * @return self |
288 | 288 | * @throws InvalidArgumentException |
289 | 289 | */ |
290 | - public function union( $graphs /* graphs ... */ ) { |
|
291 | - call_user_func_array( array( $this->graphBuilder, 'union' ), func_get_args() ); |
|
290 | + public function union($graphs /* graphs ... */) { |
|
291 | + call_user_func_array(array($this->graphBuilder, 'union'), func_get_args()); |
|
292 | 292 | return $this; |
293 | 293 | } |
294 | 294 | |
@@ -299,8 +299,8 @@ discard block |
||
299 | 299 | * @return self |
300 | 300 | * @throws InvalidArgumentException |
301 | 301 | */ |
302 | - public function subquery( QueryBuilder $query ) { |
|
303 | - $this->graphBuilder->subquery( $query ); |
|
302 | + public function subquery(QueryBuilder $query) { |
|
303 | + $this->graphBuilder->subquery($query); |
|
304 | 304 | return $this; |
305 | 305 | } |
306 | 306 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * @return QueryBuilder |
311 | 311 | */ |
312 | 312 | public function newSubquery() { |
313 | - return new QueryBuilder( $this->prefixBuilder->getPrefixes() ); |
|
313 | + return new QueryBuilder($this->prefixBuilder->getPrefixes()); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @return GraphBuilder |
322 | 322 | */ |
323 | 323 | public function newSubgraph() { |
324 | - return new GraphBuilder( $this->usageValidator ); |
|
324 | + return new GraphBuilder($this->usageValidator); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | /** |
@@ -331,10 +331,10 @@ discard block |
||
331 | 331 | * @return self |
332 | 332 | * @throws InvalidArgumentException |
333 | 333 | */ |
334 | - public function groupBy( $expressions /* expressions ... */ ) { |
|
335 | - $expressions = is_array( $expressions ) ? $expressions : func_get_args(); |
|
334 | + public function groupBy($expressions /* expressions ... */) { |
|
335 | + $expressions = is_array($expressions) ? $expressions : func_get_args(); |
|
336 | 336 | |
337 | - $this->modifierBuilder->groupBy( $expressions ); |
|
337 | + $this->modifierBuilder->groupBy($expressions); |
|
338 | 338 | return $this; |
339 | 339 | } |
340 | 340 | |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | * @return self |
346 | 346 | * @throws InvalidArgumentException |
347 | 347 | */ |
348 | - public function having( $expression ) { |
|
349 | - $this->modifierBuilder->having( $expression ); |
|
348 | + public function having($expression) { |
|
349 | + $this->modifierBuilder->having($expression); |
|
350 | 350 | return $this; |
351 | 351 | } |
352 | 352 | |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | * @return self |
359 | 359 | * @throws InvalidArgumentException |
360 | 360 | */ |
361 | - public function orderBy( $expression, $direction = 'ASC' ) { |
|
362 | - $this->modifierBuilder->orderBy( $expression, $direction ); |
|
361 | + public function orderBy($expression, $direction = 'ASC') { |
|
362 | + $this->modifierBuilder->orderBy($expression, $direction); |
|
363 | 363 | return $this; |
364 | 364 | } |
365 | 365 | |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | * @return self |
371 | 371 | * @throws InvalidArgumentException |
372 | 372 | */ |
373 | - public function limit( $limit ) { |
|
374 | - $this->modifierBuilder->limit( $limit ); |
|
373 | + public function limit($limit) { |
|
374 | + $this->modifierBuilder->limit($limit); |
|
375 | 375 | return $this; |
376 | 376 | } |
377 | 377 | |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | * @return self |
383 | 383 | * @throws InvalidArgumentException |
384 | 384 | */ |
385 | - public function offset( $offset ) { |
|
386 | - $this->modifierBuilder->offset( $offset ); |
|
385 | + public function offset($offset) { |
|
386 | + $this->modifierBuilder->offset($offset); |
|
387 | 387 | return $this; |
388 | 388 | } |
389 | 389 | |
@@ -395,9 +395,9 @@ discard block |
||
395 | 395 | * @throws InvalidArgumentException |
396 | 396 | * @throws RangeException |
397 | 397 | */ |
398 | - public function getSPARQL( $includePrefixes = true ) { |
|
399 | - if ( !is_bool( $includePrefixes ) ) { |
|
400 | - throw new InvalidArgumentException( '$includePrefixes has to be a bool' ); |
|
398 | + public function getSPARQL($includePrefixes = true) { |
|
399 | + if (!is_bool($includePrefixes)) { |
|
400 | + throw new InvalidArgumentException('$includePrefixes has to be a bool'); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | $this->usageValidator->validate(); |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | } |
414 | 414 | |
415 | 415 | private function formatSelects() { |
416 | - return empty( $this->selects ) ? '*' : implode( ' ', $this->selects ); |
|
416 | + return empty($this->selects) ? '*' : implode(' ', $this->selects); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | /** |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | */ |
435 | 435 | public function format() { |
436 | 436 | $formatter = new QueryFormatter(); |
437 | - return $formatter->format( $this->getSPARQL() ); |
|
437 | + return $formatter->format($this->getSPARQL()); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | } |
@@ -74,19 +74,19 @@ discard block |
||
74 | 74 | * @param int $options |
75 | 75 | * @throws InvalidArgumentException |
76 | 76 | */ |
77 | - public function validate( $expression, $options ) { |
|
78 | - if ( !is_string( $expression ) ) { |
|
79 | - throw new InvalidArgumentException( '$expression has to be a string.' ); |
|
77 | + public function validate($expression, $options) { |
|
78 | + if (!is_string($expression)) { |
|
79 | + throw new InvalidArgumentException('$expression has to be a string.'); |
|
80 | 80 | } |
81 | 81 | |
82 | - if ( !$this->matches( $expression, $options ) ) { |
|
83 | - throw new InvalidArgumentException( '$expression has to be a ' . |
|
84 | - implode( ' or a ', $this->getOptionNames( $options ) ) . ', got ' . $expression |
|
82 | + if (!$this->matches($expression, $options)) { |
|
83 | + throw new InvalidArgumentException('$expression has to be a ' . |
|
84 | + implode(' or a ', $this->getOptionNames($options)) . ', got ' . $expression |
|
85 | 85 | ); |
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | - private function getOptionNames( $options ) { |
|
89 | + private function getOptionNames($options) { |
|
90 | 90 | $names = array( |
91 | 91 | 'variable' => self::VALIDATE_VARIABLE, |
92 | 92 | 'IRI' => self::VALIDATE_IRI, |
@@ -98,69 +98,69 @@ discard block |
||
98 | 98 | 'function with variable assignment' => self::VALIDATE_FUNCTION_AS |
99 | 99 | ); |
100 | 100 | |
101 | - $names = array_filter( $names, function( $key ) use ( $options ) { |
|
101 | + $names = array_filter($names, function($key) use ($options) { |
|
102 | 102 | return $options & $key; |
103 | 103 | } ); |
104 | 104 | |
105 | - return array_keys( $names ); |
|
105 | + return array_keys($names); |
|
106 | 106 | } |
107 | 107 | |
108 | - private function matches( $expression, $options ) { |
|
109 | - return $this->isVariable( $expression, $options ) || |
|
110 | - $this->isIRI( $expression, $options ) || |
|
111 | - $this->isPrefix( $expression, $options ) || |
|
112 | - $this->isPrefixedIri( $expression, $options ) || |
|
113 | - $this->isValue( $expression, $options ) || |
|
114 | - $this->isPath( $expression, $options ) || |
|
115 | - $this->isFunction( $expression, $options ) || |
|
116 | - $this->isFunctionAs( $expression, $options ); |
|
108 | + private function matches($expression, $options) { |
|
109 | + return $this->isVariable($expression, $options) || |
|
110 | + $this->isIRI($expression, $options) || |
|
111 | + $this->isPrefix($expression, $options) || |
|
112 | + $this->isPrefixedIri($expression, $options) || |
|
113 | + $this->isValue($expression, $options) || |
|
114 | + $this->isPath($expression, $options) || |
|
115 | + $this->isFunction($expression, $options) || |
|
116 | + $this->isFunctionAs($expression, $options); |
|
117 | 117 | } |
118 | 118 | |
119 | - private function isVariable( $expression, $options ) { |
|
119 | + private function isVariable($expression, $options) { |
|
120 | 120 | return $options & self::VALIDATE_VARIABLE && |
121 | - $this->regexHelper->matchesRegex( '\{variable}', $expression ); |
|
121 | + $this->regexHelper->matchesRegex('\{variable}', $expression); |
|
122 | 122 | } |
123 | 123 | |
124 | - private function isIRI( $expression, $options ) { |
|
124 | + private function isIRI($expression, $options) { |
|
125 | 125 | return $options & self::VALIDATE_IRI && |
126 | - $this->regexHelper->matchesRegex( '\{iri}', $expression ); |
|
126 | + $this->regexHelper->matchesRegex('\{iri}', $expression); |
|
127 | 127 | } |
128 | 128 | |
129 | - private function isPrefix( $expression, $options ) { |
|
129 | + private function isPrefix($expression, $options) { |
|
130 | 130 | return $options & self::VALIDATE_PREFIX && |
131 | - $this->regexHelper->matchesRegex( '\{prefix}', $expression ); |
|
131 | + $this->regexHelper->matchesRegex('\{prefix}', $expression); |
|
132 | 132 | } |
133 | 133 | |
134 | - private function isPrefixedIri( $expression, $options ) { |
|
134 | + private function isPrefixedIri($expression, $options) { |
|
135 | 135 | return $options & self::VALIDATE_PREFIXED_IRI && |
136 | - $this->regexHelper->matchesRegex( '\{prefixed_iri}', $expression ); |
|
136 | + $this->regexHelper->matchesRegex('\{prefixed_iri}', $expression); |
|
137 | 137 | } |
138 | 138 | |
139 | - private function isValue( $expression, $options ) { |
|
139 | + private function isValue($expression, $options) { |
|
140 | 140 | return $options & self::VALIDATE_NATIVE && |
141 | - $this->regexHelper->matchesRegex( '\{native}', $expression ); |
|
141 | + $this->regexHelper->matchesRegex('\{native}', $expression); |
|
142 | 142 | } |
143 | 143 | |
144 | - private function isPath( $expression, $options ) { |
|
144 | + private function isPath($expression, $options) { |
|
145 | 145 | return $options & self::VALIDATE_PATH && |
146 | - $this->regexHelper->matchesRegex( '\{path}', $expression ); |
|
146 | + $this->regexHelper->matchesRegex('\{path}', $expression); |
|
147 | 147 | } |
148 | 148 | |
149 | - private function isFunction( $expression, $options ) { |
|
149 | + private function isFunction($expression, $options) { |
|
150 | 150 | // @todo this might not be complete |
151 | 151 | return $options & self::VALIDATE_FUNCTION && |
152 | - $this->regexHelper->matchesRegex( '\{function}', $expression ) && |
|
153 | - $this->checkBrackets( $expression ); |
|
152 | + $this->regexHelper->matchesRegex('\{function}', $expression) && |
|
153 | + $this->checkBrackets($expression); |
|
154 | 154 | } |
155 | 155 | |
156 | - private function checkBrackets( $expression ) { |
|
157 | - $expression = $this->regexHelper->escapeSequences( $expression ); |
|
158 | - return substr_count( $expression, '(' ) === substr_count( $expression, ')' ); |
|
156 | + private function checkBrackets($expression) { |
|
157 | + $expression = $this->regexHelper->escapeSequences($expression); |
|
158 | + return substr_count($expression, '(') === substr_count($expression, ')'); |
|
159 | 159 | } |
160 | 160 | |
161 | - private function isFunctionAs( $expression, $options ) { |
|
161 | + private function isFunctionAs($expression, $options) { |
|
162 | 162 | return $options & self::VALIDATE_FUNCTION_AS && |
163 | - $this->regexHelper->matchesRegex( '\(\{function} AS \{variable}\)', $expression ); |
|
163 | + $this->regexHelper->matchesRegex('\(\{function} AS \{variable}\)', $expression); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | } |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | * @param string[] $options one of queryParam, formatParam or userAgent |
37 | 37 | * @param Http|null $http |
38 | 38 | */ |
39 | - public function __construct( $url, array $options = array(), Http $http = null ) { |
|
39 | + public function __construct($url, array $options = array(), Http $http = null) { |
|
40 | 40 | $this->url = $url; |
41 | - $this->options = array_merge( array( |
|
41 | + $this->options = array_merge(array( |
|
42 | 42 | 'queryParam' => 'query', |
43 | 43 | 'formatParam' => 'format', |
44 | 44 | 'userAgent' => 'Asparagus/Asparagus 0.1' |
45 | - ), $options ); |
|
46 | - $this->http = $http ?: new Http( $this->options['userAgent'] ); |
|
45 | + ), $options); |
|
46 | + $this->http = $http ?: new Http($this->options['userAgent']); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -55,26 +55,26 @@ discard block |
||
55 | 55 | * @throws RangeException |
56 | 56 | * @throws RuntimeException |
57 | 57 | */ |
58 | - public function execute( $query ) { |
|
59 | - if ( $query instanceof QueryBuilder ) { |
|
58 | + public function execute($query) { |
|
59 | + if ($query instanceof QueryBuilder) { |
|
60 | 60 | $query = $query->getSPARQL(); |
61 | 61 | } |
62 | 62 | |
63 | - if ( !is_string( $query ) ) { |
|
64 | - throw new InvalidArgumentException( '$query has to be a string or an instance of QueryBuilder' ); |
|
63 | + if (!is_string($query)) { |
|
64 | + throw new InvalidArgumentException('$query has to be a string or an instance of QueryBuilder'); |
|
65 | 65 | } |
66 | 66 | |
67 | - $result = $this->getResult( $query ); |
|
67 | + $result = $this->getResult($query); |
|
68 | 68 | return $result['results']; |
69 | 69 | } |
70 | 70 | |
71 | - private function getResult( $query ) { |
|
72 | - $result = $this->http->request( $this->url, array( |
|
71 | + private function getResult($query) { |
|
72 | + $result = $this->http->request($this->url, array( |
|
73 | 73 | $this->options['queryParam'] => $query, |
74 | 74 | $this->options['formatParam'] => 'json' |
75 | - ) ); |
|
75 | + )); |
|
76 | 76 | |
77 | - return json_decode( $result, true ); |
|
77 | + return json_decode($result, true); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | } |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | * @param string $expression |
68 | 68 | * @return bool |
69 | 69 | */ |
70 | - public function matchesRegex( $regex, $expression ) { |
|
71 | - return preg_match( '/^' . $this->resolveMagic( $regex ) . '$/i', $expression ) === 1; |
|
70 | + public function matchesRegex($regex, $expression) { |
|
71 | + return preg_match('/^' . $this->resolveMagic($regex) . '$/i', $expression) === 1; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | * @param int $group |
81 | 81 | * @return string[] |
82 | 82 | */ |
83 | - public function getMatches( $regex, $expression, $group = 1 ) { |
|
84 | - if ( preg_match_all( |
|
85 | - '/' . $this->resolveMagic( $regex ) . '/', |
|
86 | - $this->escapeSequences( $expression ), |
|
83 | + public function getMatches($regex, $expression, $group = 1) { |
|
84 | + if (preg_match_all( |
|
85 | + '/' . $this->resolveMagic($regex) . '/', |
|
86 | + $this->escapeSequences($expression), |
|
87 | 87 | $matches |
88 | - ) ) { |
|
88 | + )) { |
|
89 | 89 | return $matches[$group]; |
90 | 90 | } |
91 | 91 | |
@@ -99,14 +99,14 @@ discard block |
||
99 | 99 | * @param string[] $replacements |
100 | 100 | * @return string |
101 | 101 | */ |
102 | - public function escapeSequences( $expression, &$replacements = null ) { |
|
102 | + public function escapeSequences($expression, &$replacements = null) { |
|
103 | 103 | $replacements = array(); |
104 | 104 | // @todo this is not completely safe but works in most cases |
105 | 105 | // @todo for strings use http://stackoverflow.com/questions/171480/regex-grabbing-values-between-quotation-marks |
106 | 106 | return preg_replace_callback( |
107 | 107 | '/("([^\"]*)"|\<([^\>]*)\>)/', |
108 | - function( $match ) use ( &$replacements ) { |
|
109 | - $key = '<' . md5( $match[0] ) . '>'; |
|
108 | + function($match) use (&$replacements) { |
|
109 | + $key = '<' . md5($match[0]) . '>'; |
|
110 | 110 | $replacements[$key] = $match[0]; |
111 | 111 | return $key; |
112 | 112 | }, |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | ); |
115 | 115 | } |
116 | 116 | |
117 | - private function resolveMagic( $regex ) { |
|
117 | + private function resolveMagic($regex) { |
|
118 | 118 | $magics = array( |
119 | 119 | '\{variable}' => self::$variable, |
120 | 120 | '\{iri}' => self::$iri, |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | '\{function}' => $this->getFunctionRegex() |
127 | 127 | ); |
128 | 128 | |
129 | - return strtr( $regex, $magics ); |
|
129 | + return strtr($regex, $magics); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | private function getPrefixedIriRegex() { |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | } |
140 | 140 | |
141 | 141 | private function getFunctionRegex() { |
142 | - $allowed = array_merge( self::$functions, array( '\<' . self::$iri . '\>', self::$prefix . ':', self::$variable, '!' ) ); |
|
143 | - return '(' . implode( '|', $allowed ) . ').*'; |
|
142 | + $allowed = array_merge(self::$functions, array('\<' . self::$iri . '\>', self::$prefix . ':', self::$variable, '!')); |
|
143 | + return '(' . implode('|', $allowed) . ').*'; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | } |