Skip to content

Commit b2c9a1c

Browse files
Add functions to easily call static methods
1 parent 9ffa5ad commit b2c9a1c

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
"friendsofphp/php-cs-fixer": "^3.0"
5959
},
6060
"autoload": {
61+
"files": [
62+
"src/functions.php"
63+
],
6164
"psr-4": {
6265
"WikibaseSolutions\\CypherDSL\\": "src/"
6366
}

src/functions.php

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of php-cypher-dsl.
4+
*
5+
* Copyright (C) 2021- Wikibase Solutions
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace WikibaseSolutions\CypherDSL;
11+
12+
use WikibaseSolutions\CypherDSL\Expressions\Exists;
13+
use WikibaseSolutions\CypherDSL\Expressions\Literals\Boolean;
14+
use WikibaseSolutions\CypherDSL\Expressions\Literals\Float_;
15+
use WikibaseSolutions\CypherDSL\Expressions\Literals\Integer;
16+
use WikibaseSolutions\CypherDSL\Expressions\Literals\List_;
17+
use WikibaseSolutions\CypherDSL\Expressions\Literals\Map;
18+
use WikibaseSolutions\CypherDSL\Expressions\Literals\String_;
19+
use WikibaseSolutions\CypherDSL\Expressions\RawExpression;
20+
use WikibaseSolutions\CypherDSL\Expressions\Variable;
21+
use WikibaseSolutions\CypherDSL\Patterns\Node;
22+
use WikibaseSolutions\CypherDSL\Patterns\Relationship;
23+
24+
/**
25+
* @see Query::new()
26+
*/
27+
function query(): Query
28+
{
29+
return Query::new();
30+
}
31+
32+
/**
33+
* @see Query::node()
34+
*/
35+
function node(string $label = null): Node
36+
{
37+
return Query::node($label);
38+
}
39+
40+
/**
41+
* @see Query::relationship()
42+
*/
43+
function relationship(array $direction): Relationship
44+
{
45+
return Query::relationship($direction);
46+
}
47+
48+
/**
49+
* @see Query::variable()
50+
*/
51+
function variable(?string $variable = null): Variable
52+
{
53+
return Query::variable($variable);
54+
}
55+
56+
/**
57+
* @see Query::literal()
58+
*/
59+
function literal($literal = null)
60+
{
61+
return Query::literal($literal);
62+
}
63+
64+
/**
65+
* @see Query::boolean()
66+
*/
67+
function boolean(bool $value): Boolean
68+
{
69+
return Query::boolean($value);
70+
}
71+
72+
/**
73+
* @see Query::string()
74+
*/
75+
function string(string $value): String_
76+
{
77+
return Query::string($value);
78+
}
79+
80+
/**
81+
* @see Query::integer()
82+
*/
83+
function integer(int $value): Integer
84+
{
85+
return Query::integer($value);
86+
}
87+
88+
/**
89+
* @see Query::float()
90+
*/
91+
function float(float $value): Float_
92+
{
93+
return Query::float($value);
94+
}
95+
96+
/**
97+
* @see Query::list()
98+
*/
99+
function list_(array $value): List_
100+
{
101+
return Query::list($value);
102+
}
103+
104+
/**
105+
* @see Query::map()
106+
*/
107+
function map(array $value): Map
108+
{
109+
return Query::map($value);
110+
}
111+
112+
/**
113+
* @see Query::function()
114+
*/
115+
function function_(): string
116+
{
117+
return Query::function();
118+
}
119+
120+
/**
121+
* @see Query::rawExpression()
122+
*/
123+
function raw(string $expression): RawExpression
124+
{
125+
return Query::rawExpression($expression);
126+
}
127+
128+
/**
129+
* @see Query::exists()
130+
*/
131+
function exists($match, $where = null, bool $insertParentheses = false): Exists
132+
{
133+
return Query::exists($match, $where, $insertParentheses);
134+
}

0 commit comments

Comments
 (0)