Skip to content

Commit 39bb34c

Browse files
author
Jonathon Hill
committed
feat: Initial version
0 parents  commit 39bb34c

19 files changed

+4758
-0
lines changed

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: compwright
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: write
10+
issues: write
11+
pull-requests: write
12+
13+
jobs:
14+
release-please:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: googleapis/release-please-action@v4
18+
with:
19+
# this assumes that you have created a personal access token
20+
# (PAT) and configured it as a GitHub action secret named
21+
# `MY_RELEASE_PLEASE_TOKEN` (this secret name is not important).
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
# this is a built-in strategy in release-please, see "Action Inputs"
24+
# for more options
25+
release-type: php

.github/workflows/run-tests.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
jobs:
10+
php-tests:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
php: [8.3, 8.4]
16+
os: [ubuntu-latest]
17+
18+
name: PHP${{ matrix.php }}
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v1
23+
24+
- name: Setup PHP
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: ${{ matrix.php }}
28+
29+
- name: Install dependencies
30+
run: composer install --no-interaction
31+
32+
- name: Execute Lint and Unit Tests
33+
run: make test

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/build
2+
/vendor
3+
composer.phar
4+
.DS_Store
5+
*.cache

.php-cs-fixer.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
$dirs = [
4+
__DIR__ . '/src',
5+
__DIR__ . '/tests',
6+
];
7+
8+
$rules = [
9+
'@PSR12' => true,
10+
'array_syntax' => ['syntax' => 'short'],
11+
'no_unused_imports' => true,
12+
'single_line_comment_style' => true,
13+
'single_line_comment_spacing' => true,
14+
'control_structure_braces' => true,
15+
'control_structure_continuation_position' => true,
16+
'no_useless_else' => true,
17+
'no_superfluous_elseif' => true,
18+
'simplified_if_return' => true,
19+
];
20+
21+
$finder = PhpCsFixer\Finder::create()
22+
->in($dirs);
23+
24+
return (new PhpCsFixer\Config())
25+
->setRules($rules)
26+
->setFinder($finder)
27+
->setCacheFile(__DIR__ . '/.cache/.php-cs-fixer.cache');

CONTRIBUTING.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Contributing
2+
3+
Contributions are **welcome** and will be fully **credited**.
4+
5+
We accept contributions via Pull Requests on [Github](https://github.com/compwright/oauth2-housecallpro).
6+
7+
8+
## Pull Requests
9+
10+
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
11+
12+
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
13+
14+
- **Document any change in behaviour** - Make sure the README and any other relevant documentation are kept up-to-date.
15+
16+
- **Consider our release cycle** - We try to follow SemVer. Randomly breaking public APIs is not an option.
17+
18+
- **Create topic branches** - Don't ask us to pull from your master branch.
19+
20+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
21+
22+
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.
23+
24+
- **Ensure tests pass!** - Please run the tests (see below) before submitting your pull request, and make sure they pass. We won't accept a patch until all tests pass.
25+
26+
- **Ensure no coding standards violations** - Please run PHP Code Sniffer using the PSR-2 standard (see below) before submitting your pull request. A violation will cause the build to fail, so please make sure there are no violations. We can't accept a patch if the build fails.
27+
28+
29+
## Running Tests
30+
31+
``` bash
32+
$ composer run-script test
33+
```
34+
35+
**Happy coding**!

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2025 Jonathon Hill
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
test:
2+
vendor/bin/phpstan analyse --level 9 src tests
3+
XDEBUG_MODE=coverage vendor/bin/phpunit --display-warnings --display-deprecations src tests
4+
5+
style:
6+
vendor/bin/php-cs-fixer fix

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# FreeDesktop.org os-release file reader for PHP
2+
3+
[![Latest Version](https://img.shields.io/github/release/compwright/php-os-release.svg?style=flat-square)](https://github.com/compwright/php-os-release/releases)
4+
[![Total Downloads](https://img.shields.io/packagist/dt/compwright/php-os-release.svg?style=flat-square)](https://packagist.org/packages/compwright/php-os-release)
5+
6+
For more information about the os-release standard, see https://www.freedesktop.org/software/systemd/man/os-release.html
7+
8+
This library will attempt to read and parse the two standard os-release information files, in order of precedence:
9+
10+
1. /etc/os-release
11+
2. /usr/lib/os-release
12+
13+
If no file exists, or if the file cannot be read, an OsReleaseException will be thrown.
14+
15+
## Installation
16+
17+
To install, use composer:
18+
19+
```
20+
composer require compwright/php-os-release
21+
```
22+
23+
## Usage
24+
25+
```php
26+
use CompWright\PhpOsRelease\OsReleaseReader;
27+
28+
$reader = new OsReleaseReader();
29+
$osRelease = $reader();
30+
31+
// Access via property or array access
32+
$version = $osRelease->version;
33+
34+
// or:
35+
$version = $osRelease['VERSION'];
36+
```
37+
38+
## Testing
39+
40+
``` bash
41+
$ make test
42+
```
43+
44+
## Contributing
45+
46+
Please see [CONTRIBUTING](https://github.com/compwright/php-os-release/blob/master/CONTRIBUTING.md) for details.
47+
48+
## License
49+
50+
The MIT License (MIT). Please see [License File](https://github.com/compwright/php-os-release/blob/master/LICENSE) for more information.

composer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "compwright/php-os-release",
3+
"description": "FreeDesktop.org os-release file reader for PHP",
4+
"license": "MIT",
5+
"authors": [
6+
{
7+
"name": "Jonathon Hill",
8+
"email": "jonathon@compwright.com",
9+
"homepage": "https://compwright.com"
10+
}
11+
],
12+
"require": {
13+
"php": "^8.3"
14+
},
15+
"require-dev": {
16+
"friendsofphp/php-cs-fixer": "^3.74",
17+
"phpunit/phpunit": "^12.0",
18+
"phpstan/phpstan": "^2.1"
19+
},
20+
"autoload": {
21+
"psr-4": {
22+
"CompWright\\PhpOsRelease\\": "src/"
23+
}
24+
},
25+
"autoload-dev": {
26+
"psr-4": {
27+
"CompWright\\PhpOsRelease\\": "tests/"
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)