Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  fix github badge
  remove halsey journal
  fix incorrect example
  update docs
  add mkdocs
  • Loading branch information
Baptouuuu committed Jun 2, 2024
2 parents e8409d2 + 4087969 commit 5ed45c6
Show file tree
Hide file tree
Showing 19 changed files with 326 additions and 172 deletions.
34 changes: 18 additions & 16 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
name: Documentation

on:
push:
branches: [master]

permissions:
contents: write
jobs:
publish:
deploy:
runs-on: ubuntu-latest
name: 'Publish documentation'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
- uses: actions/checkout@v4
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: actions/setup-python@v5
with:
php-version: '8.0'
- name: Install halsey/journal
run: composer global require halsey/journal
- name: Generate
run: composer global exec 'journal generate'
- name: Push
uses: peaceiris/actions-gh-pages@v3
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./.tmp_journal/
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/vendor
/.phpunit.result.cache
/.phpunit.cache
/.cache
74 changes: 0 additions & 74 deletions .journal

This file was deleted.

6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This command is intended to be run on your computer
serve-doc:
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material

build-doc:
docker run --rm -it -v ${PWD}:/docs squidfunk/mkdocs-material build
Binary file added documentation/assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
22 changes: 22 additions & 0 deletions documentation/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 113 additions & 0 deletions documentation/assets/stylesheets/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
@font-face {
font-family: "Monaspace Neon";
font-weight: normal;
font-style: normal;
src: url("../fonts/MonaspaceNeon-Regular.woff");
}

:root {
--md-code-font: "Monaspace Neon";
}

:root {
--light-md-code-hl-number-color: #f76d47;
--light-md-code-hl-function-color: #6384b9;
--light-md-code-hl-operator-color: #39adb5;
--light-md-code-hl-constant-color: #7c4dff;
--light-md-code-hl-string-color: #9fc06f;
--light-md-code-hl-punctuation-color: #39adb5;
--light-md-code-hl-keyword-color: #7c4dff;
--light-md-code-hl-variable-color: #80cbc4;
--light-md-code-hl-comment-color: #ccd7da;
--light-md-code-bg-color: #fafafa;
--light-md-code-fg-color: #ffb62c;
--light-md-code-hl-variable-color: #6384b9;
--dark-md-code-hl-number-color: #f78c6c;
--dark-md-code-hl-function-color: #82aaff;
--dark-md-code-hl-operator-color: #89ddff;
--dark-md-code-hl-constant-color: #c792ea;
--dark-md-code-hl-string-color: #c3e88d;
--dark-md-code-hl-punctuation-color: #89ddff;
--dark-md-code-hl-keyword-color: #c792ea;
--dark-md-code-hl-variable-color: #e8f9f9;
--dark-md-code-hl-comment-color: #546e7a;
--dark-md-code-bg-color: #263238;
--dark-md-code-fg-color: #ffcb6b;
--dark-md-code-hl-variable-color: #82aaff;
}

@media (prefers-color-scheme: light) {
.language-php > * {
--md-code-hl-number-color: var(--light-md-code-hl-number-color);
--md-code-hl-function-color: var(--light-md-code-hl-function-color);
--md-code-hl-operator-color: var(--light-md-code-hl-operator-color);
--md-code-hl-constant-color: var(--light-md-code-hl-constant-color);
--md-code-hl-string-color: var(--light-md-code-hl-string-color);
--md-code-hl-punctuation-color: var(--light-md-code-hl-punctuation-color);
--md-code-hl-keyword-color: var(--light-md-code-hl-keyword-color);
--md-code-hl-variable-color: var(--light-md-code-hl-variable-color);
--md-code-hl-comment-color: var(--light-md-code-hl-comment-color);
--md-code-bg-color: var(--light-md-code-bg-color);
--md-code-fg-color: var(--light-md-code-fg-color);
}

.language-php .na {
--md-code-hl-variable-color: var(--light-md-code-hl-variable-color);
}
}

[data-md-color-media="(prefers-color-scheme: light)"] .language-php > * {
--md-code-hl-number-color: var(--light-md-code-hl-number-color);
--md-code-hl-function-color: var(--light-md-code-hl-function-color);
--md-code-hl-operator-color: var(--light-md-code-hl-operator-color);
--md-code-hl-constant-color: var(--light-md-code-hl-constant-color);
--md-code-hl-string-color: var(--light-md-code-hl-string-color);
--md-code-hl-punctuation-color: var(--light-md-code-hl-punctuation-color);
--md-code-hl-keyword-color: var(--light-md-code-hl-keyword-color);
--md-code-hl-variable-color: var(--light-md-code-hl-variable-color);
--md-code-hl-comment-color: var(--light-md-code-hl-comment-color);
--md-code-bg-color: var(--light-md-code-bg-color);
--md-code-fg-color: var(--light-md-code-fg-color);
}

[data-md-color-media="(prefers-color-scheme: light)"] .language-php .na {
--md-code-hl-variable-color: var(--light-md-code-hl-variable-color);
}

@media (prefers-color-scheme: dark) {
.language-php > * {
--md-code-hl-number-color: var(--dark-md-code-hl-number-color);
--md-code-hl-function-color: var(--dark-md-code-hl-function-color);
--md-code-hl-operator-color: var(--dark-md-code-hl-operator-color);
--md-code-hl-constant-color: var(--dark-md-code-hl-constant-color);
--md-code-hl-string-color: var(--dark-md-code-hl-string-color);
--md-code-hl-punctuation-color: var(--dark-md-code-hl-punctuation-color);
--md-code-hl-keyword-color: var(--dark-md-code-hl-keyword-color);
--md-code-hl-variable-color: var(--dark-md-code-hl-variable-color);
--md-code-hl-comment-color: var(--dark-md-code-hl-comment-color);
--md-code-bg-color: var(--dark-md-code-bg-color);
--md-code-fg-color: var(--dark-md-code-fg-color);
}

.language-php .na {
--md-code-hl-variable-color: var(--dark-md-code-hl-variable-color);
}
}

[data-md-color-media="(prefers-color-scheme: dark)"] .language-php > * {
--md-code-hl-number-color: var(--dark-md-code-hl-number-color);
--md-code-hl-function-color: var(--dark-md-code-hl-function-color);
--md-code-hl-operator-color: var(--dark-md-code-hl-operator-color);
--md-code-hl-constant-color: var(--dark-md-code-hl-constant-color);
--md-code-hl-string-color: var(--dark-md-code-hl-string-color);
--md-code-hl-punctuation-color: var(--dark-md-code-hl-punctuation-color);
--md-code-hl-keyword-color: var(--dark-md-code-hl-keyword-color);
--md-code-hl-variable-color: var(--dark-md-code-hl-variable-color);
--md-code-hl-comment-color: var(--dark-md-code-hl-comment-color);
--md-code-bg-color: var(--dark-md-code-bg-color);
--md-code-fg-color: var(--dark-md-code-fg-color);
}

[data-md-color-media="(prefers-color-scheme: dark)"] .language-php .na {
--md-code-hl-variable-color: var(--dark-md-code-hl-variable-color);
}
6 changes: 5 additions & 1 deletion documentation/connections/lazy.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ use Formal\AccessLayer\{
};
use Innmind\Url\Url;

$connection = new Lazy(static fn() => PDO::of(Url::of('mysql://user:[email protected]:3306/database_name')));
$connection = new Lazy(
static fn() => PDO::of(
Url::of('mysql://user:[email protected]:3306/database_name'),
),
);
```

By passing a callable to the constructor allows you to use [whatever implementation](own.md) of a `Connection` you wish to lazy load.
8 changes: 4 additions & 4 deletions documentation/connections/logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ $connection = Logger::psr(
);
```

> [!NOTE]
> it doesn't log any information about the returned rows to prevent _unwrapping_ the deferred `Sequence` returned by [`PDO`](pdo.md).
!!! note ""
It doesn't log any information about the returned rows to prevent _unwrapping_ the deferred `Sequence` returned by [`PDO`](pdo.md).

> [!IMPORTANT]
> it won't log any errors for lazy queries since the query is not executed until the first call on the sequence.
!!! warning ""
It won't log any errors for lazy queries since the query is not executed until the first call on the sequence.
77 changes: 22 additions & 55 deletions documentation/connections/own.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,63 +40,30 @@ final class Sentry implements Connection

An important part of extending the behaviour of the connection with your own logic is to not change the current behaviour that other code may rely upon. This library helps you make sure you don't break these behaviours by providing you properties.

Below is an example of a PHPUnit test case that you can extend to add your specific test cases:
Below is an example of running properties via [BlackBox](https://innmind.github.io/BlackBox/):

```php
use PHPUnit\Framework\TestCase;
use Innmind\BlackBox\PHPUnit\BlackBox;
use Properties\Formal\AccessLayer\Connection;

class SentryTest extends TestCase
{
use BlackBox;

public function setUp(): void
{
Connection::seed($this->connection());
}

// you can add here test cases like in any other PHPUnit class

/**
* @dataProvider properties
*/
public function testHoldProperty($property)
{
$this
->forAll($property)
->then(function($property) {
$connection = $this->connection();

if (!$property->applicableTo($connection)) {
$this->markTestSkipped();
}

$property->ensureHeldBy($connection);
});
}

public function testHoldProperties()
{
$this
->forAll(Connection::properties())
->disableShrinking()
->then(function($properties) {
$properties->ensureHeldBy($this->connection());
});
}

public function properties(): iterable
{
foreach (Connection::list() as $property) {
yield [$property];
}
}

private function connection(): PDO
{
return new Sentry(/* add the arguments of your implementation here */);
}
use Innmind\BlackBox\Set;
use Properties\Formal\AccessLayer\Connection as Properties;

$sentry = new Sentry(/* add the arguments of your implementation here */);
$connection = Set\Call::of(static function() use ($sentry) {
Properties::seed($sentry);

return $sentry;
});

yield properties(
'Sentry properties',
Properties::any(),
$connection,
);

foreach (Properties::list() as $property) {
yield property(
$property,
$connection,
)->named('Sentry');
}
```

Expand Down
4 changes: 2 additions & 2 deletions documentation/connections/pdo.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ $connection = PDO::of(Url::of('mysql://user:[email protected]:3306/database_name?cha

When executing a [query](../queries/sql.md) through this connection it will return a [deferred `Sequence`](https://innmind.github.io/Immutable/SEQUENCE.html#defer) of rows. This means that the rows returned from the database are only loaded once you iterate over the sequence. (Queries with the named constructor `::onDemand()` will return a lazy `Sequence`).

> [!IMPORTANT]
> as soon as you instanciate the class it will open a connection to the database, if you want to open it upon first query take a look at the [`Lazy` connection](lazy.md).
!!! note ""
As soon as you instanciate the class it will open a connection to the database, if you want to open it upon first query take a look at the [`Lazy` connection](lazy.md).
Loading

0 comments on commit 5ed45c6

Please sign in to comment.