Skip to content

Commit

Permalink
Increased type safety (#10)
Browse files Browse the repository at this point in the history
* run tests for main branch

* review method args types for 'src/Auth'

* review method args types for 'src/AQL'

* review method args types for 'src/Batch'

* Update README.md

* review method args types for 'src/Auth' and 'src/AQL'

* review method args types for 'src/Collection' and 'src/Document'

* review method args types for 'src/DataStructures' and 'src/Http'

* inline return for exceptions on 'src/Admin'

* inline return for exceptions on 'Database' and 'Transactions' namespaces

* declare class attribute types on 'Graph', 'View' and 'Exceptions' namespaces

* gh actions: bump 'github/codeql-action/upload-sarif' version

* update docs

* type checks for 'Graph' namespace

* reviewed docs
  • Loading branch information
lucassouzavieira authored May 15, 2024
1 parent 78db272 commit 8a088e4
Show file tree
Hide file tree
Showing 68 changed files with 594 additions and 807 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ jobs:

# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
4 changes: 2 additions & 2 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: PHP

on:
push:
branches: [ develop ]
branches: [ main, develop ]
pull_request:
branches: [ develop ]
branches: [ main, develop ]

permissions:
contents: read
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ build/
cache/
coverage.xml
*.phar
docs/

# Ignore documentation generation script
documentation.php
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
## Installation

### Using composer
- Run the command bellow on your project root.<br>
- Run the command below on your project root.<br>
`composer require lvieira/arangodb-php-odm`

## Usage
Expand All @@ -27,7 +27,7 @@ $connection = new Connection([
'database' => 'YourDatabase',
]);

// Alternatively, you can set an host and a port to connect
// Alternatively, you can set a host and a port to connect
$connection = new Connection([
'host' => 'http://yourarangohost',
'port' => 8529,
Expand Down Expand Up @@ -68,25 +68,25 @@ $connection = new Connection([

$database = $connection->getDatabase();

// With database object, we can retrive informations about it.
// With a database object, we can retrieve information about it.
$infoAboutCurrentDatabase = $database->getInfo();

// Check if database has a collection
// Check if the database has a collection
if($database->hasCollection('my_collection_name')){
echo "Collection exists!";
} else {
echo "Collection doesn't exists";
echo "Collection doesn't exist";
}

// We can also create collections in database
// We can also create collections in the database
$collection = $database->createCollection('my_new_colletion');

// Or retrieve existing collections
$collection = $database->getCollection('my_existing_collection');

// With Database class we can create and drop databases
// With the Database class we can create and drop databases

// Lists the databases on server
// Lists the databases on the server
$dbList = Database::list($connection);

// You can create a new database using the existing connection
Expand Down Expand Up @@ -116,13 +116,13 @@ $connection = new Connection([

$database = $connection->getDatabase();

// If collection exists on database, the object will be a representation of it.
// If a collection exists on a database, the object will represent it.
$collection = new Collection('my_collection_name', $database);

// If collection not exists, you can create it with method 'save'
// If the collection does not exist, you can create it with the method 'save'
$collection->save();

// Get all documents from collection
// Get all documents from the collection
foreach ($collection->all() as $document){
// Do something.
}
Expand Down Expand Up @@ -175,7 +175,7 @@ $document->save();
$document->status = 'active';
$document->save(); // Will update your document on server;

// Delete the document from collection.
// Delete the document from the collection.
$document->delete();
```

Expand Down Expand Up @@ -206,7 +206,7 @@ try {
$transaction = new JavascriptTransaction($this->getConnectionObject(), $action, $options);
$result = $transaction->execute(); // Will return 1.
} catch (TransactionException $transactionException) {
// Throws an TransactionException in case of error.
// Throws a TransactionException in case of error.
return $transactionException->getMessage();
}
```
Expand Down Expand Up @@ -265,8 +265,8 @@ try {

## Documentation

Check the [full documentation](https://lucassouzavieira.github.io/arangodb-php-odm/v1.0.0/index.html) of project:
Check the [API Reference](https://lucassouzavieira.github.io/arangodb-php-odm/).

## Contributing

[Check how contribute in this project](CONTRIBUTING.md)
[Check how to contribute to this project](CONTRIBUTING.md)
4 changes: 2 additions & 2 deletions docs/classes/ArangoDB-AQL-AQL.html
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ <h4 class="phpdocumentor-element__name" id="method_functions">
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/AQL/AQL.php"><a href="files/src-aql-aql.html"><abbr title="src/AQL/AQL.php">AQL.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">63</span>
<span class="phpdocumentor-element-found-in__line">62</span>

<a href="classes/ArangoDB-AQL-AQL.html#source-view.63" class="phpdocumentor-element-found-in__source" data-line="63" data-modal="source-view" data-src="files/src/AQL/AQL.php.txt"></a>
<a href="classes/ArangoDB-AQL-AQL.html#source-view.62" class="phpdocumentor-element-found-in__source" data-line="62" data-modal="source-view" data-src="files/src/AQL/AQL.php.txt"></a>
</aside>

<p class="phpdocumentor-summary">Returns all registered AQL user functions.</p>
Expand Down
8 changes: 4 additions & 4 deletions docs/classes/ArangoDB-AQL-BindContainer.html
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ <h4 id="toc-methods">
<span>
&nbsp;: mixed </span>
</dt>
<dd>Get a value by it&#039;s key</dd>
<dd>Get a value by its key</dd>

<dt class="phpdocumentor-table-of-contents__entry -method -public">
<a href="classes/ArangoDB-AQL-BindContainer.html#method_getAll">getAll()</a>
Expand Down Expand Up @@ -705,11 +705,11 @@ <h4 class="phpdocumentor-element__name" id="method_get">
<a href="classes/ArangoDB-AQL-BindContainer.html#source-view.76" class="phpdocumentor-element-found-in__source" data-line="76" data-modal="source-view" data-src="files/src/DataStructures/ArrayList.php.txt"></a>
</aside>

<p class="phpdocumentor-summary">Get a value by it&#039;s key</p>
<p class="phpdocumentor-summary">Get a value by its key</p>

<code class="phpdocumentor-code phpdocumentor-signature ">
<span class="phpdocumentor-signature__visibility">public</span>
<span class="phpdocumentor-signature__name">get</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type"><a href=""></a>&nbsp;</span><span class="phpdocumentor-signature__argument__name">$key</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">mixed</span></code>
<span class="phpdocumentor-signature__name">get</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">int|string&nbsp;</span><span class="phpdocumentor-signature__argument__name">$key</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">mixed</span></code>

<div class="phpdocumentor-label-line">
</div>
Expand All @@ -718,7 +718,7 @@ <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
<dl class="phpdocumentor-argument-list">
<dt class="phpdocumentor-argument-list__entry">
<span class="phpdocumentor-signature__argument__name">$key</span>
: <span class="phpdocumentor-signature__argument__return-type"><a href=""></a></span>
: <span class="phpdocumentor-signature__argument__return-type">int|string</span>
</dt>
<dd class="phpdocumentor-argument-list__definition">
<section class="phpdocumentor-description"><p>Key to verify on list.</p>
Expand Down
Loading

0 comments on commit 8a088e4

Please sign in to comment.