News from the Orient library: OrientDB query-builder goes out

There are times to celebrate, like this one, that I was expecting since 2 months; a moment I delayed because of an amount of things that you can’t even imagine.

But as I stated earlier, a product should respect its estimated lifecycle and be released with the announced features: that’s why I’m proud to announce the immediate availability of the beta-3 tag of Orient, which ( stand up who does not know what it is ), last time I repeat it, is a library which lets you easily work with OrientDB from PHP.

What’s new?

Nothing that special.

As I remarked via Twitter and in the first post I linked in this article, the beta-3 was a solidifying release:

Swishes the code

As always, we tried to make it clear enough for Doctrine 1.2 users to be able not to get lost writing a simple SELECT:

Creating a simple SQL query
1
2
3
4
5
6
7
8
9
10
<?php

use Orient\Query;

$query = new Query('users');
$query->where('username = ? AND gender = ?', array('admin', 'male'));
$query->orWhere('gender = ?', "female");

echo $query->getRaw();
// SELECT FROM users WHERE username = "admin" AND gender = "male" OR gender = "female"

You can obviously do more complex stuff or use any of OrientDB SQL-like operators:

More examples of SQL queries and operators
1
2
3
4
5
6
7
8
<?php

$query->revoke('myPermission')->to('user1')->on('cluster'); // Revoke access to a user

$query->findReferences('12:0'); // Who's referring to record 12:0?

$query->from(array('index:inEdges'));
$query->between('12:0', '12:40'); // look at some indexes between two ranges

Status of the library

If you want, before looking at some nice pictures a few lines below, read these considerations about the current state of Orient.

…there we go: the most boring parts of the library are done and I’m glad these moments are past, from now.

As far as I – now – know, a few refactorings will be performed on the QB, but the test coverage is high enough to let us perform these operations without being scared at all: the first thing I want to work on are the formatters and the entire way the query tokens are handled; since the formatters introduce a lot of static code I primarily want to see if I can replace them with validators, then re-think the entire structure of the tokens, because the implementation is a bit sucky nowadays ( I want to type-hint them! ).

But don’t think these 2 steps will really be the first things I will do: with the beginning of August, thus vacations, I’ll spend lot of time on the data mapper, which is the most funny and complex part of the whole system; being able to spend some time during this month will let us have a really buggy preview of the final mapper by the end of august, I suppose.

Magic pictures

Developers like metrics and related pictures.

I want to share with you a few pictures and number from the beta-3 tag of the library, but please, be aware that without having thousand of systems that use it in production all of these numbers are meaningless! :)

Here is the code coverage, generated by PHPUnit:

and some really interesting numbers, like cyclomatic complexity, thanks to PHPLOC:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Directories:                                         32
Files:                                               84
Lines of Code (LOC):                               6622
  Cyclomatic Complexity / Lines of Code:           0.03
Comment Lines of Code (CLOC):                      3411
Non-Comment Lines of Code (NCLOC):                 3211
Namespaces:                                          33
Interfaces:                                          17
Classes:                                             67
  Abstract:                                           3 (4.48%)
  Concrete:                                          64 (95.52%)
  Average Class Length (NCLOC):                      40
Methods:                                            351
  Scope:
    Non-Static:                                     306 (87.18%)
    Static:                                          45 (12.82%)
  Visibility:
    Public:                                         278 (79.20%)
    Non-Public:                                      73 (20.80%)
  Average Method Length (NCLOC):                      7
  Cyclomatic Complexity / Number of Methods:       1.31
Anonymous Functions:                                  3
Functions:                                            0
Constants:                                           32
Global constants:                                     0
Class constants:                                     32

…without forgetting the fact that I created a report.sh file that can be run to inspect the health of the code; for example, take a lot at the phpDepend pyramid:

Last but not least, if you like interactive PHPDOC tools ( I don’t, they all suck hard ), I set up a small Doxygen init script that you can use to generate the documentation:

1
doxygen Docs/orient.d

then you can look at Docs/html to read the generated documentation.

So, what are you waiting for? Go out there and get oriented!

comments powered by Disqus