Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/cs-fixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: PHP CS Fixer

on:
push:
pull_request:
paths:
- '**/*.php'
workflow_dispatch:

jobs:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: Psalm Static Analysis

on:
push:
pull_request:
paths:
- '**/*.php'
workflow_dispatch:

jobs:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: CI Pipeline
name: PHP Tests

on:
push:
pull_request:
workflow_dispatch:

concurrency:
Expand Down
1 change: 1 addition & 0 deletions .php-cs-fixer.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"php":"8.3.16","version":"3.68.5:v3.68.5#7bedb718b633355272428c60736dc97fb96daf27","indent":" ","lineEnding":"\n","rules":{"binary_operator_spaces":{"default":"at_least_single_space"},"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_empty_anonymous_classes":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_parentheses":true,"no_blank_lines_after_class_opening":true,"no_extra_blank_lines":{"tokens":["use"]},"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_space_around_construct":{"constructs_followed_by_a_single_space":["abstract","as","case","catch","class","const_import","do","else","elseif","final","finally","for","foreach","function","function_import","if","insteadof","interface","namespace","new","private","protected","public","static","switch","trait","try","use","use_lambda","while"],"constructs_preceded_by_a_single_space":["as","else","elseif","use_lambda"]},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_operator_spaces":{"only_dec_inc":true},"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"attribute_placement":"ignore","on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"strict_param":true},"hashes":{"tests\/resources\/expected\/complex-query-profile.php":"c0d16588e70d32588ec2e55ba5ae5873","tests\/Unit\/Neo4jExceptionUnitTest.php":"e07e604496e0e4032d2798ee9d2cb1b2","tests\/Unit\/ResultRowTest.php":"b4b307579a75da8307d6d65eb5548cae","tests\/Unit\/Neo4jQueryAPIUnitTest.php":"87e08aca0ccef5589c88bd7249e39496","tests\/Unit\/Neo4jRequestFactoryTest.php":"ebc6d5ee7790df4d69a5b555ad48ff5a","tests\/Unit\/AuthenticationTest.php":"746b185bcfb47a925e35b5b79b854fab","tests\/Integration\/Neo4jQueryAPIIntegrationTest.php":"43f34ad1774e3eeb133a9e3bb96f191d","tests\/Integration\/Neo4jTransactionIntegrationTest.php":"35fcbd5afbec5bb59f35040d9d6c518f","tests\/Integration\/Neo4jOGMTest.php":"e03f51ef605ca818763f3897d7a30830","src\/OGM.php":"211c087b78fca69390701e2f505e46fe","src\/Neo4jQueryAPI.php":"a7a505057617a2de3a94a73065254ecb","src\/BearerAuthentication.php":"51b5f02280a43838465cffa8974648c6","src\/Enums\/AccessMode.php":"88b5c70c4716cc68bcb86e2f162dd347","src\/Results\/ResultRow.php":"92dc1ec9315fa5236a79468ffaf9a60c","src\/Results\/ResultSet.php":"372faa2af185b25b804be1974c34b1ae","src\/Exception\/Neo4jException.php":"89c4c090cd3ba6e94c13eab7ebd0588c","src\/NoAuth.php":"2267e8a5b07aeaaab3165bb105b10807","src\/loginConfig.php":"47e9993051fc556a7fc28bc8f9a01caa","src\/AuthenticateInterface.php":"1da849c5d5b88439e01543d5d5b9f8d9","src\/BasicAuthentication.php":"ab50275cc6841d88d289a63d86ecb118","src\/Configuration.php":"fabfe6acf58bb0bda76453ace4f0757d","src\/ResponseParser.php":"e32270966c3a618bcb5ea9c6497748be","src\/Neo4jRequestFactory.php":"e3279d36e54032c6acf92df10ac47f07","src\/Objects\/Path.php":"e8091a19eb4e70ced4f8f7364dbe78be","src\/Objects\/Node.php":"ac679671f513c6c996dbf75a66fcacb2","src\/Objects\/Authentication.php":"f31af1c057be0f490cc2dba365f03b31","src\/Objects\/ProfiledQueryPlanArguments.php":"02b5fa2d50fec5d0fb0c4ada55ebda69","src\/Objects\/Person.php":"cee5594450a015103e12d4cbe186f167","src\/Objects\/Point.php":"4115d8d1b85a0d6e37b79d303237bcd0","src\/Objects\/ResultSet.php":"a5ba56fc6c6e250c22b183ac26dfd68e","src\/Objects\/ProfiledQueryPlan.php":"75ab6c3ad2ce97675a8e6478d17ac4d9","src\/Objects\/Bookmarks.php":"2c3e7229ce9b56c0352155b3feaac9bb","src\/Objects\/ResultCounters.php":"a9372c98fe7bede10cb004af30ea502f","src\/Objects\/Relationship.php":"e344e22d5a41f1795f3310d55ea51c20","src\/Transaction.php":"ff5454897ddbcc4fc2a984ecb90a90fd","src\/Authentication\/BearerAuthentication.php":"08a9e3c01d3833255cd51c94a17f1aa3","src\/Authentication\/NoAuth.php":"71cc7d784b9d98c62d2342faf38f7dc4","src\/Authentication\/AuthenticateInterface.php":"65b5a1074e11fba04362e754ad97023f","src\/Authentication\/BasicAuthentication.php":"c37b7ef26a59c032ac2a6a7b91c5adae"}}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@

"scripts": {
"cs": "vendor/bin/php-cs-fixer fix --dry-run --diff --allow-risky=yes",
"cs:fix": "vendor/bin/php-cs-fixer fix --allow-risky=yes"
"cs:fix": "vendor/bin/php-cs-fixer fix --allow-risky=yes",
"psalm": "vendor/bin/psalm"
}

}
4 changes: 4 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<PossiblyUnusedProperty errorLevel="suppress"/>
<PossiblyUnusedMethod errorLevel="suppress"/>
</issueHandlers>
</psalm>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Neo4j\QueryAPI;
namespace Neo4j\QueryAPI\Authentication;

use Psr\Http\Message\RequestInterface;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Neo4j\QueryAPI;
namespace Neo4j\QueryAPI\Authentication;

use Psr\Http\Message\RequestInterface;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Neo4j\QueryAPI;
namespace Neo4j\QueryAPI\Authentication;

use Psr\Http\Message\RequestInterface;

Expand Down
2 changes: 1 addition & 1 deletion src/NoAuth.php → src/Authentication/NoAuth.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Neo4j\QueryAPI;
namespace Neo4j\QueryAPI\Authentication;

use Psr\Http\Message\RequestInterface;

Expand Down
18 changes: 18 additions & 0 deletions src/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Neo4j\QueryAPI;

use Neo4j\QueryAPI\Objects\Bookmarks;
use Neo4j\QueryAPI\Enums\AccessMode;

class Configuration
{
public function __construct(
public readonly string $baseUri,
public readonly string $database = 'neo4j',
public readonly bool $includeCounters = true,
public readonly Bookmarks $bookmarks = new Bookmarks([]),
public readonly AccessMode $accessMode = AccessMode::WRITE,
) {
}
}
9 changes: 9 additions & 0 deletions src/Enums/AccessMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Neo4j\QueryAPI\Enums;

enum AccessMode: string
{
case READ = 'READ';
case WRITE = 'WRITE';
}
35 changes: 16 additions & 19 deletions src/Exception/Neo4jException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
/**
* @api
*/

class Neo4jException extends Exception
{
private readonly string $errorCode;
Expand All @@ -18,25 +17,38 @@ class Neo4jException extends Exception
public function __construct(
array $errorDetails = [],
int $statusCode = 0,
?\Throwable $previous = null
?\Throwable $previous = null,
) {
$this->errorCode = $errorDetails['code'] ?? 'Neo.UnknownError';
$errorParts = explode('.', $this->errorCode);
$this->errorType = $errorParts[1] ?? null;
$this->errorSubType = $errorParts[2] ?? null;
$this->errorName = $errorParts[3] ?? null;


$message = $errorDetails['message'] ?? 'An unknown error occurred.';
parent::__construct($message, $statusCode, $previous);
}

/**
* Create a Neo4jException instance from a Neo4j error response array.
*
* @param array $response The error response from Neo4j.
* @param \Throwable|null $exception Optional previous exception for chaining.
* @return self
*/
public static function fromNeo4jResponse(array $response, ?\Throwable $exception = null): self
{
$errorDetails = $response['errors'][0] ?? ['message' => 'Unknown error', 'code' => 'Neo.UnknownError'];


return new self($errorDetails, previous: $exception);
}

public function getErrorCode(): string
{
return $this->errorCode;
}


public function getType(): ?string
{
return $this->errorType;
Expand All @@ -51,19 +63,4 @@ public function getName(): ?string
{
return $this->errorName;
}

/**
* Create a Neo4jException instance from a Neo4j error response array.
*
* @param array $response The error response from Neo4j.
* @param \Throwable|null $exception Optional previous exception for chaining.
* @return self
*/
public static function fromNeo4jResponse(array $response, ?\Throwable $exception = null): self
{
$errorDetails = $response['errors'][0] ?? [];
$statusCode = $errorDetails['statusCode'] ?? 0;

return new self($errorDetails, (int)$statusCode, $exception);
}
}
Loading