Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  update the documentation
  fix incompatible query
  add support for neo4j 4.0
  replace travis by github ci
  CS
  methods with side effects must return void
  rename has() to contains()
  CS
  rename __toString to toString
  make constant private
  add psalm
  update deps
  require php 7.4
  update to phpunit 8
  remove useless script
  add docker compose to boot a neo4j database
  remove dbal from the object graph
  • Loading branch information
Baptouuuu committed Mar 26, 2020
2 parents 4241ed8 + 71e71d2 commit d8fb258
Show file tree
Hide file tree
Showing 152 changed files with 3,345 additions and 5,093 deletions.
4 changes: 1 addition & 3 deletions .gitattributes
@@ -1,7 +1,5 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.scrutinizer.yml export-ignore
/circle.yml export-ignore
/phpunit.xml.dist export-ignore
/fixtures export-ignore
/Tests export-ignore
/tests export-ignore
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,70 @@
name: CI

on: [push]

jobs:
phpunit:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
php-version: ['7.4']
neo4j-version: ['3.4', '4.0']
name: 'PHPUnit - PHP/${{ matrix.php-version }} - OS/${{ matrix.os }} - Neo4j/${{ matrix.neo4j-version }}'
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup Neo4j
uses: baptouuuu/setup-neo4j@v1.1.0
with:
tag: ${{ matrix.neo4j-version }}
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: xdebug
ini-values: xdebug.max_nesting_level=2048
- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Dependencies
run: composer install --no-progress
- name: PHPUnit
run: vendor/bin/phpunit --coverage-clover=coverage.clover
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
psalm:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['7.4']
name: 'Psalm - PHP/${{ matrix.php-version }}'
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Dependencies
run: composer install --no-progress
- name: Psalm
run: vendor/bin/psalm --shepherd
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
composer.lock
vendor
cache
.phpunit.result.cache
7 changes: 0 additions & 7 deletions .scrutinizer.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

16 changes: 7 additions & 9 deletions README.md
@@ -1,10 +1,8 @@
# Neo4j-ONM

| `master` | `develop` |
|----------|-----------|
| [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Innmind/neo4j-onm/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Innmind/neo4j-onm/?branch=master) | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Innmind/neo4j-onm/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/Innmind/neo4j-onm/?branch=develop) |
| [![Code Coverage](https://scrutinizer-ci.com/g/Innmind/neo4j-onm/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Innmind/neo4j-onm/?branch=master) | [![Code Coverage](https://scrutinizer-ci.com/g/Innmind/neo4j-onm/badges/coverage.png?b=develop)](https://scrutinizer-ci.com/g/Innmind/neo4j-onm/?branch=develop) |
| [![Build Status](https://scrutinizer-ci.com/g/Innmind/neo4j-onm/badges/build.png?b=master)](https://scrutinizer-ci.com/g/Innmind/neo4j-onm/build-status/master) | [![Build Status](https://scrutinizer-ci.com/g/Innmind/neo4j-onm/badges/build.png?b=develop)](https://scrutinizer-ci.com/g/Innmind/neo4j-onm/build-status/develop) |
[![Build Status](https://github.com/Innmind/neo4j-onm/workflows/CI/badge.svg)](https://github.com/Innmind/neo4j-onm/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/Innmind/neo4j-onm/branch/develop/graph/badge.svg)](https://codecov.io/gh/Innmind/neo4j-onm)
[![Type Coverage](https://shepherd.dev/github/Innmind/neo4j-onm/coverage.svg)](https://shepherd.dev/github/Innmind/neo4j-onm)

This an _ORM_ for the [Neo4j](http://neo4j.com/) graph database, with an emphasis on Domain Driven Design (DDD). It will allow you to easily build `Entities`, `Repositories` and query them via `Specification`s. Another important aspect is that each block of this library is fully replaceable.

Expand All @@ -29,7 +27,7 @@ Each entity is fully managed by its own `Repository`, meaning it's used to `add`

**Note**: for performance issues, when you `add` an entity to its repository it's not directly inserted in the graph.

To access an entity repository, you'll use a `Manager` which only contains 4 methods: `connection`, `repository`, `flush` and `identities`. The first one gives you access to the DBAL [`Connection`](https://github.com/Innmind/neo4j-dbal/blob/master/Connection.php) so you can open/commit transactions. The method `repository` takes the entity class in order to return the associated repository. `flush` will persist in the graph all of your modifications from your repositories. Finally, `identities` allows you to generate a new identity of the specified type
To access an entity repository, you'll use a `Manager` which only contains 4 methods: `connection`, `repository`, `flush` and `identities`. The first one gives you access to the DBAL [`Connection`](https://github.com/Innmind/neo4j-dbal/blob/master/src/Connection.php) so you can open/commit transactions. The method `repository` takes the entity class in order to return the associated repository. `flush` will persist in the graph all of your modifications from your repositories. Finally, `identities` allows you to generate a new identity of the specified type

When you `flush` the sequence of how the modifications are persisted is as follow:

Expand Down Expand Up @@ -161,7 +159,7 @@ Now that you know how to add/remove, let's learn how query our entities back fro
$image = images->get(new Uuid($_GET['wished_image_id']));
```

**Note**: the usage of `$_GET` here is only to be framework agnostic, but even if you'd use it would be pretty safe as `Uuid` validates the data (as you can see [here](Identity/Uuid.php#L20)).
**Note**: the usage of `$_GET` here is only to be framework agnostic, but even if you'd use it would be pretty safe as `Uuid` validates the data (as you can see [here](src/Identity/Uuid.php#L20)).

But accessing entities through their identifiers is not enough, that's why a repository as a method called `matching` which allows only a single parameter that has to be a [specification](https://github.com/Innmind/Specification).

Expand Down Expand Up @@ -195,7 +193,7 @@ By default there's only 7 types you can use for your entities' properties:
* `SetType` (similar as `ArrayType` except it uses the immutable [`Set`](https://github.com/Innmind/Immutable#set))
* `StringType`

To add your own type you need to create a class implementing [`Type.php`](Type.php).
To add your own type you need to create a class implementing [`Type.php`](src/Type.php).


#### Entity Translators
Expand Down Expand Up @@ -257,7 +255,7 @@ $services = bootstrap(

By default this library only use UUIDs as identity objects. But you can easily add your own kind of identity object.

You need to create the identity class implementing [`Identity`](Identity.php) and the corresponding generator implementing [`Generator`](Identity/Generator.php).
You need to create the identity class implementing [`Identity`](src/Identity.php) and the corresponding generator implementing [`Generator`](src/Identity/Generator.php).

```php
use Innmind\Neo4j\ONM\{
Expand Down
3 changes: 3 additions & 0 deletions codecov.yml
@@ -0,0 +1,3 @@
ignore:
- graph.php
- fixtures/
26 changes: 12 additions & 14 deletions composer.json
Expand Up @@ -15,13 +15,13 @@
"issues": "http://github.com/Innmind/neo4j-onm/issues"
},
"require": {
"php": "~7.2",
"innmind/neo4j-dbal": "~5.0",
"innmind/immutable": "~2.10",
"php": "~7.4",
"innmind/neo4j-dbal": "~6.0",
"innmind/immutable": "~3.5",
"ramsey/uuid": "^3.2",
"innmind/reflection": "~3.0",
"innmind/reflection": "~4.0",
"innmind/specification": "~2.0",
"innmind/event-bus": "~3.0"
"innmind/event-bus": "~4.0"
},
"autoload": {
"psr-4": {
Expand All @@ -36,15 +36,13 @@
}
},
"require-dev": {
"phpunit/phpunit": "~7.0",
"innmind/time-continuum": "^1.0",
"innmind/command-bus": "^3.0",
"innmind/cli": "^1.5",
"innmind/object-graph": "^1.2",
"innmind/server-control": "^2.7"
},
"scripts": {
"test": "vendor/bin/phpunit --colors=always"
"phpunit/phpunit": "~8.0",
"innmind/time-continuum": "~2.0",
"innmind/command-bus": "~4.0",
"innmind/cli": "~2.0",
"innmind/object-graph": "~2.0",
"innmind/server-control": "~3.0",
"vimeo/psalm": "^3.10"
},
"suggest": {
"innmind/time-continuum": "To be able to use point_in_time type",
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,7 @@
version: '2'
services:
neo4j:
image: neo4j:3.4
ports:
- '7474:7474'
- '7687:7687'
12 changes: 9 additions & 3 deletions graph.php
Expand Up @@ -15,6 +15,8 @@
use Innmind\ObjectGraph\{
Graph,
Visualize,
Visitor\FlagDependencies,
Visitor\RemoveDependenciesSubGraph,
};
use Innmind\Immutable\Set;

Expand All @@ -32,6 +34,12 @@ protected function main(Environment $env, OperatingSystem $os): void

$graph = new Graph;
$visualize = new Visualize;
$flag = new FlagDependencies($dbal);
$remove = new RemoveDependenciesSubGraph;

$node = $graph($package['manager']);
$flag($node);
$remove($node);

$os
->control()
Expand All @@ -40,9 +48,7 @@ protected function main(Environment $env, OperatingSystem $os): void
Command::foreground('dot')
->withShortOption('Tsvg')
->withShortOption('o', 'graph.svg')
->withInput(
$visualize($graph($package['manager']))
)
->withInput($visualize($node))
)
->wait();
}
Expand Down

0 comments on commit d8fb258

Please sign in to comment.