22
33use Bolt \Bolt ;
44use Bolt \connection \{Socket , StreamSocket };
5- use Bolt \protocol \{AProtocol , Response , V4_3 , V4_1 , V4 , V3 };
5+ use Bolt \protocol \{AProtocol , Response , V5_2 , V4_3 , V4_1 , V4 };
66
77/**
88 * Class Memgraph - adapter for Bolt library
@@ -25,21 +25,21 @@ class Memgraph
2525
2626 /**
2727 * Set your authentification
28- * @see \ Bolt\helpers\Auth
28+ * @link https://github.com/neo4j-php/ Bolt?tab=readme-ov-file#authentification
2929 */
3030 public static array $ auth ;
3131
3232 public static string $ host = '127.0.0.1 ' ;
3333 public static int $ port = 7687 ;
3434 public static float $ timeout = 15 ;
3535
36- private static AProtocol |V4_3 |V4_1 |V4 | V3 |null $ protocol = null ;
36+ private static AProtocol |V5_2 | V4_3 |V4_1 |V4 |null $ protocol = null ;
3737 private static array $ statistics ;
3838
3939 /**
4040 * Get connection protocol for bolt communication
4141 */
42- protected static function getProtocol (): AProtocol |V4_3 |V4_1 |V4 | V3
42+ protected static function getProtocol (): AProtocol |V5_2 | V4_3 |V4_1 |V4
4343 {
4444 if (is_null (self ::$ protocol )) {
4545 try {
@@ -57,10 +57,10 @@ protected static function getProtocol(): AProtocol|V4_3|V4_1|V4|V3
5757 self ::$ protocol = $ bolt ->setProtocolVersions (5.2 , 4.3 , 4.1 , 4.0 )->build ();
5858
5959 if (version_compare (self ::$ protocol ->getVersion (), '5.2 ' , '>= ' )) {
60- self ::$ protocol ->hello ();
61- self ::$ protocol ->logon (self ::$ auth );
60+ self ::$ protocol ->hello ()-> getResponse () ;
61+ self ::$ protocol ->logon (self ::$ auth )-> getResponse () ;
6262 } else {
63- self ::$ protocol ->hello (self ::$ auth );
63+ self ::$ protocol ->hello (self ::$ auth )-> getResponse () ;
6464 }
6565
6666 register_shutdown_function (function () {
@@ -91,19 +91,19 @@ public static function query(string $query, array $params = [], array $extra = [
9191 $ run = $ all = null ;
9292 try {
9393 $ runResponse = self ::getProtocol ()->run ($ query , $ params , $ extra )->getResponse ();
94- if ($ runResponse ->getSignature () != Response:: SIGNATURE_SUCCESS ) {
95- throw new Exception (implode (' ' , $ runResponse ->getContent () ));
94+ if ($ runResponse ->signature != \ Bolt \ enum \Signature:: SUCCESS ) {
95+ throw new Exception (implode (' ' , $ runResponse ->content ));
9696 }
97- $ run = $ runResponse ->getContent () ;
97+ $ run = $ runResponse ->content ;
9898
9999 foreach (self ::getProtocol ()->pull ()->getResponses () as $ response ) {
100- if ($ response ->getSignature () == Response:: SIGNATURE_IGNORED || $ response ->getSignature () == Response:: SIGNATURE_FAILURE ) {
101- throw new Exception (implode (' ' , $ runResponse ->getContent () ));
100+ if ($ response ->signature == \ Bolt \ enum \Signature:: IGNORED || $ response ->signature == \ Bolt \ enum \Signature:: FAILURE ) {
101+ throw new Exception (implode (' ' , $ runResponse ->content ));
102102 }
103- $ all [] = $ response ->getContent () ;
103+ $ all [] = $ response ->content ;
104104 }
105105 } catch (Exception $ e ) {
106- self ::getProtocol ()->reset ();
106+ self ::getProtocol ()->reset ()-> getResponse () ;
107107 self ::handleException ($ e );
108108 return [];
109109 }
@@ -116,7 +116,7 @@ public static function query(string $query, array $params = [], array $extra = [
116116 if (is_callable (self ::$ logHandler )) {
117117 $ time = 0 ;
118118 foreach ($ last as $ key => $ value ) {
119- if (substr ($ key , - 5 ) == '_time ' ) {
119+ if (str_ends_with ($ key , '_time ' ) ) {
120120 $ time += $ value ;
121121 }
122122 }
@@ -173,15 +173,15 @@ public static function begin(array $extra = []): bool
173173 {
174174 try {
175175 $ response = self ::getProtocol ()->begin ($ extra )->getResponse ();
176- if ($ response ->getSignature () != Response:: SIGNATURE_SUCCESS ) {
177- throw new Exception (implode (' ' , $ response ->getContent () ));
176+ if ($ response ->signature != \ Bolt \ enum \Signature:: SUCCESS ) {
177+ throw new Exception (implode (' ' , $ response ->content ));
178178 }
179179 if (is_callable (self ::$ logHandler )) {
180180 call_user_func (self ::$ logHandler , 'BEGIN TRANSACTION ' );
181181 }
182182 return true ;
183183 } catch (Exception $ e ) {
184- self ::getProtocol ()->reset ();
184+ self ::getProtocol ()->reset ()-> getResponse () ;
185185 self ::handleException ($ e );
186186 }
187187 return false ;
@@ -196,15 +196,15 @@ public static function commit(): bool
196196 {
197197 try {
198198 $ response = self ::getProtocol ()->commit ()->getResponse ();
199- if ($ response ->getSignature () != Response:: SIGNATURE_SUCCESS ) {
200- throw new Exception (implode (' ' , $ response ->getContent () ));
199+ if ($ response ->signature != \ Bolt \ enum \Signature:: SUCCESS ) {
200+ throw new Exception (implode (' ' , $ response ->content ));
201201 }
202202 if (is_callable (self ::$ logHandler )) {
203203 call_user_func (self ::$ logHandler , 'COMMIT TRANSACTION ' );
204204 }
205205 return true ;
206206 } catch (Exception $ e ) {
207- self ::getProtocol ()->reset ();
207+ self ::getProtocol ()->reset ()-> getResponse () ;
208208 self ::handleException ($ e );
209209 }
210210 return false ;
@@ -219,15 +219,15 @@ public static function rollback(): bool
219219 {
220220 try {
221221 $ response = self ::getProtocol ()->rollback ()->getResponse ();
222- if ($ response ->getSignature () != Response:: SIGNATURE_SUCCESS ) {
223- throw new Exception (implode (' ' , $ response ->getContent () ));
222+ if ($ response ->signature != \ Bolt \ enum \Signature:: SUCCESS ) {
223+ throw new Exception (implode (' ' , $ response ->content ));
224224 }
225225 if (is_callable (self ::$ logHandler )) {
226226 call_user_func (self ::$ logHandler , 'ROLLBACK TRANSACTION ' );
227227 }
228228 return true ;
229229 } catch (Exception $ e ) {
230- self ::getProtocol ()->reset ();
230+ self ::getProtocol ()->reset ()-> getResponse () ;
231231 self ::handleException ($ e );
232232 }
233233 return false ;
0 commit comments