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
4 changes: 4 additions & 0 deletions .codacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exclude_paths:
- ".github/**"
- "example/**"
- "test/**"
48 changes: 23 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
name: CI

on: [push]
on:
push:
pull_request:

permissions:
contents: read
actions: read

jobs:
composer:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ 8.1, 8.2, 8.3, 8.4 ]
php: [ 8.2, 8.3, 8.4, 8.5 ]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Cache Composer dependencies
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
Expand All @@ -22,22 +28,24 @@ jobs:
uses: php-actions/composer@v6
with:
php_version: ${{ matrix.php }}
php_extensions: pcntl

- name: Archive build
run: mkdir /tmp/github-actions/ && tar -cvf /tmp/github-actions/build.tar ./
run: mkdir /tmp/github-actions/ && tar --exclude=".git" -cvf /tmp/github-actions/build.tar ./

- name: Upload build archive for test runners
uses: actions/upload-artifact@v4
with:
name: build-artifact-${{ matrix.php }}
path: /tmp/github-actions
retention-days: 1

phpunit:
runs-on: ubuntu-latest
needs: [ composer ]
strategy:
matrix:
php: [ 8.1, 8.2, 8.3, 8.4 ]
php: [ 8.2, 8.3, 8.4, 8.5 ]

outputs:
coverage: ${{ steps.store-coverage.outputs.coverage_text }}
Expand Down Expand Up @@ -72,7 +80,7 @@ jobs:
needs: [ phpunit ]
strategy:
matrix:
php: [ 8.1, 8.2, 8.3, 8.4 ]
php: [ 8.2, 8.3, 8.4, 8.5 ]

steps:
- uses: actions/checkout@v4
Expand All @@ -87,13 +95,16 @@ jobs:

- name: Upload to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: ${{ github.repository }}

phpstan:
runs-on: ubuntu-latest
needs: [ composer ]
strategy:
matrix:
php: [ 8.1, 8.2, 8.3, 8.4 ]
php: [ 8.2, 8.3, 8.4, 8.5 ]

steps:
- uses: actions/download-artifact@v4
Expand All @@ -109,13 +120,15 @@ jobs:
with:
php_version: ${{ matrix.php }}
path: src/
level: 6
memory_limit: 256M

phpmd:
runs-on: ubuntu-latest
needs: [ composer ]
strategy:
matrix:
php: [ 8.1, 8.2, 8.3, 8.4 ]
php: [ 8.2, 8.3, 8.4, 8.5 ]

steps:
- uses: actions/download-artifact@v4
Expand All @@ -139,7 +152,7 @@ jobs:
needs: [ composer ]
strategy:
matrix:
php: [ 8.1, 8.2, 8.3, 8.4 ]
php: [ 8.2, 8.3, 8.4, 8.5 ]

steps:
- uses: actions/download-artifact@v4
Expand All @@ -156,18 +169,3 @@ jobs:
php_version: ${{ matrix.php }}
path: src/
standard: phpcs.xml

remove_old_artifacts:
runs-on: ubuntu-latest

steps:
- name: Remove old artifacts for prior workflow runs on this repository
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api "/repos/${{ github.repository }}/actions/artifacts?name=build-artifact" | jq ".artifacts[] | select(.name | startswith(\"build-artifact\")) | .id" > artifact-id-list.txt
while read id
do
echo -n "Deleting artifact ID $id ... "
gh api --method DELETE /repos/${{ github.repository }}/actions/artifacts/$id && echo "Done"
done <artifact-id-list.txt
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A Data Transfer Objects (DTO) in a programming language is a design pattern that

***

<a href="https://giub.com/PhpGt/DataObject/actions" target="_blank">
<a href="https://github.com/PhpGt/DataObject/actions" target="_blank">
<img src="https://badge.status.php.gt/dataobject-build.svg" alt="Build status" />
</a>
<a href="https://app.codacy.com/gh/PhpGt/DataObject" target="_blank">
Expand All @@ -18,7 +18,7 @@ A Data Transfer Objects (DTO) in a programming language is a design pattern that
<img src="https://badge.status.php.gt/dataobject-version.svg" alt="Current version" />
</a>
<a href="http://www.php.gt/dataobject" target="_blank">
<img src="https://badge.status.php.gt/dataobject-docs.svg" alt="PHP.Gt/DataObject documentation" />
<img src="https://badge.status.php.gt/dataobject-docs.svg" alt="PHP.GT/DataObject documentation" />
</a>

A `DataObject` has the following features:
Expand All @@ -36,7 +36,7 @@ Load an object into a `DataObject`, then pass to a third party library for proce
Due to the immutability of the `DataObject` class, there is no risk of the third party library making changes to the contents of the data.

```php
use Gt\DataObject\DataObjectBuilder;
use GT\DataObject\DataObjectBuilder;

// Create a new Builder and build the DataObject from an associative array.
// For example, data loaded from another remote data source.
Expand Down Expand Up @@ -66,6 +66,6 @@ Database::store(
Working with JSON data
----------------------

A JSON data structure is almost identical in scope to the DataObject introduced in this repository, with one key difference: JSON data can represent a primitive data type, not always key-value-pairs. Because of this, [PHP.Gt/Json is maintained separately to provide structured, type-safe, immutable JSON objects][json] as an extension to this DataObject repository.
A JSON data structure is almost identical in scope to the DataObject introduced in this repository, with one key difference: JSON data can represent a primitive data type, not always key-value-pairs. Because of this, [PHP.GT/Json is maintained separately to provide structured, type-safe, immutable JSON objects][json] as an extension to this PHP.GT/DataObject repository.

[json]: https://php.gt/json
29 changes: 25 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
},

"require-dev": {
"phpstan/phpstan": "^1.10",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^10.1",
"phpmd/phpmd": "^2.13",
"squizlabs/php_codesniffer": "^3.7"
"squizlabs/php_codesniffer": "^4.0"
},

"license": "MIT",
Expand All @@ -27,12 +27,33 @@

"autoload": {
"psr-4": {
"GT\\DataObject\\": "./src",
"Gt\\DataObject\\": "./src"
}
},
"autoload-dev": {
"psr-4": {
"Gt\\DataObject\\Test\\": "./test/phpunit"
"GT\\DataObject\\Test\\": "./test/phpunit"
}
}
},

"scripts": {
"phpunit": "vendor/bin/phpunit --configuration phpunit.xml",
"phpstan": "vendor/bin/phpstan analyse --level 6 src",
"phpcs": "vendor/bin/phpcs src --standard=phpcs.xml",
"phpmd": "vendor/bin/phpmd src/ text phpmd.xml",
"test": [
"@phpunit",
"@phpstan",
"@phpcs",
"@phpmd"
]
},

"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/phpgt"
}
]
}
Loading
Loading