Skip to content

Commit

Permalink
Carpe Diem
Browse files Browse the repository at this point in the history
  • Loading branch information
adrorocker committed Sep 18, 2024
0 parents commit 39f93cf
Show file tree
Hide file tree
Showing 52 changed files with 1,466 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Enforce Unix newlines
* text=lf

# Exclude unused files
/.gitattributes export-ignore
/.githooks export-ignore
/.github export-ignore
/.gitignore export-ignore
/coverage export-ignore
/README.md export-ignore
/phpunit.xml export-ignore
/phpcs.xml export-ignore
/phpstan.neon export-ignore
/art export-ignore
/docs export-ignore
/tests export-ignore
27 changes: 27 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

vendor/bin/phpunit --colors=always;

if [ $? -gt 0 ]
then
echo "Aborting commit ..."
exit 1
fi

vendor/bin/phpcs

if [ $? -gt 0 ]
then
echo "Aborting commit ..."
exit 1
fi

vendor/bin/phpstan analyse -c phpstan.neon

if [ $? -gt 0 ]
then
echo "Aborting commit ..."
exit 1
fi

exit 0
27 changes: 27 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

vendor/bin/phpunit --colors=always;

if [ $? -gt 0 ]
then
echo "Aborting commit ..."
exit 1
fi

vendor/bin/phpcs

if [ $? -gt 0 ]
then
echo "Aborting commit ..."
exit 1
fi

vendor/bin/phpstan analyse -c phpstan.neon

if [ $? -gt 0 ]
then
echo "Aborting commit ..."
exit 1
fi

exit 0
94 changes: 94 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: CI

on:
workflow_dispatch:
push:
branches:
- main
pull_request:

jobs:
test:
name: Test on PHP ${{ matrix.php-versions }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-versions: ['8.1', '8.2', '8.3']

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none

- name: Install composer and dependencies
uses: php-actions/composer@v6

- name: PHPUnit Tests
uses: php-actions/phpunit@v3
env:
XDEBUG_MODE: coverage
with:
bootstrap: vendor/autoload.php
configuration: phpunit.xml
php_extensions: xdebug
args: tests --coverage-clover ./coverage.xml

- name: Upload to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODE_COV_TOKEN }}
files: ./coverage.xml
verbose: true

phpstan:
name: PHPStan
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-versions: ['8.1', '8.2', '8.3']

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none

- name: Install Composer Dependencies
uses: ramsey/composer-install@v2

- name: Run phpstan
run: vendor/bin/phpstan analyse -c phpstan.neon --xdebug --no-progress
cscheck:
name: Code Sniffer check
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-versions: ['8.1', '8.2', '8.3']

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none

- name: Install Composer Dependencies
uses: ramsey/composer-install@v2

- name: Run Code Sniffer
run: vendor/bin/phpcs
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.phpunit.cache
vendor
composer.lock
.DS_Store
55 changes: 55 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Contributing

First and foremost, thank you for your interest in contributing to this package 🙏

There some ways to contribute. Some of them don't involve any coding.

- [Contributing](#contributing)
- [Spread the word](#spread-the-word)
- [Code contributions](#code-contributions)
- [Guidelines](#guidelines)
- [Running Tests](#running-tests)
- [Documentation](#documentation)

## Spread the word

This is perhaps the most impactful contribution you can make. __Spread the
word__. Online on your favorite social media channels. Offline to your dear fellow
developers who are looking for such a package 📢

## Code contributions

Contributions are welcome, and are accepted via pull requests. Please review these guidelines before submitting any pull requests.

### Guidelines

* Please follow the [PSR-12 Coding Standard](https://www.php-fig.org/psr/psr-12/).
* Ensure that the current tests pass, and if you've added something new, add the tests where relevant.
* Send a coherent commit history, making sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash](http://git-scm.com/book/en/Git-Tools-Rewriting-History) them before submitting.
* You may also need to [rebase](http://git-scm.com/book/en/Git-Branching-Rebasing) to avoid merge conflicts.

### Running Tests

You will need to install [Composer](https://getcomposer.org) before continuing.

First, install the dependencies:

```bash
$ composer install
```

Then run phpunit, phpstan and code sniffer:

```bash
$ composer check
```

If the test suite passes on your local machine you should be good to go.

> *PRO TIP* : Install the git hooks by running `composer githooks`. This will make git run phpunit, phpstan and code sniffer before committing or pushing to remote.
## Documentation

If you are adding a new feature or changing functionalities please also update the proper documentation under the `./docs` folder. We are using [docsify](https://docsify.js.org/) for the docs.

If you notice any typos or grammar issues, feel free to make a pull request with fixes or add missing documentation 📚
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Alejandro Morelos

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<p align="center">
<img style="padding: 25px" height="50" src="./art/unbounce-plus-php.png">
</p>

<p align="center">
<a href="https://packagist.org/packages/adrosoftware/unbounce-api-php-sdk">
<img alt="Latest Stable Version" src="https://img.shields.io/packagist/v/adrosoftware/unbounce-api-php-sdk.svg">
</a>
<a href="https://codecov.io/gh/adrosoftware/unbounce-api-php-sdk" >
<img src="https://codecov.io/gh/adrosoftware/unbounce-api-php-sdk/branch/main/graph/badge.svg?token=SI4NXOC1AX"/>
</a>
<a href="https://github.com/adrosoftware/unbounce-api-php-sdk/actions/workflows/ci.yml">
<img alt="Test - CI" src="https://github.com/adrosoftware/unbounce-api-php-sdk/actions/workflows/ci.yml/badge.svg">
</a>
<a href="https://github.com/adrosoftware/unbounce-api-php-sdk/blob/main/LICENSE">
<img alt="License" src="https://img.shields.io/github/license/adrosoftware/unbounce-api-php-sdk">
</a>
<img alt="Last commit" src="https://img.shields.io/github/last-commit/adrosoftware/unbounce-api-php-sdk.svg">
</p>

# Unofficial Unbounce SDK for PHP

This is a Object Oriented wrapper for the [Unbounce](https://unbounce.com/) API, written with PHP. The full Unbounce API documentation can be found [here](https://developer.unbounce.com/api_reference/).

## Documentation

To see full documentation visit the oficial [documentation](https://adrosoftware.github.io/unbounce-api-php-sdk/)

## Requirements

* PHP >= 8.1
* A [PSR-17 implementation](https://packagist.org/providers/psr/http-factory-implementation)
* A [PSR-18 implementation](https://packagist.org/providers/psr/http-client-implementation)

## How to use it

_This package is decoupled from any HTTP messaging client with help by [HTTPlug](https://httplug.io). For this reason you need to install a PSR-17 and PSR-18 implementation packages. Example: `composer require symfony/http-client nyholm/psr7`._

Require the package with [composer](https://getcomposer.org/):

```bash
composer require adrosoftware/unbounce-api-php-sdk
```

Create an instance on your codebase as follows and then you will be good to start interacting with the Circle API.

```php
<?php

declare(strict_types=1);

use AdroSoftware\UnbounceSdk\Unbounce;

$unbounce = Unbounce::make('5up3r53cr3770k3n');

// Interact with the API.

$accounts = $unbounce->accounts()->all();
```

## License

This package is licensed under the MIT License - see the [LICENSE](https://github.com/adrosoftware/unbounce-api-php-sdk/blob/main/LICENSE) file for details

## Maintainers

This library is maintained by:
- [Adro Morelos](https://github.com/adrorocker)

## Contributors

See all the contributors [here](https://github.com/adrosoftware/unbounce-api-php-sdk/graphs/contributors)
Binary file added art/unbounce-plus-php.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"name": "adrosoftware/unbounce-api-php-sdk",
"description": "A PHP SDK to interact with the unbounce.com API",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Adro Morelos",
"email": "me@adro.rocks"
}
],
"minimum-stability": "stable",
"require": {
"php": "^8.1.0",
"php-http/client-common": "^2.3",
"php-http/discovery": "^1.12",
"psr/http-client": "^1.0",
"psr/http-client-implementation": "^1.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
"symfony/options-resolver": "^6.2"
},
"require-dev": {
"guzzlehttp/guzzle": "^7.5",
"php-http/guzzle7-adapter": "^1.0",
"php-http/message": "^1.0",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.0",
"squizlabs/php_codesniffer": "^3.7",
"symfony/var-dumper": "^6.2"
},
"autoload": {
"psr-4": {
"AdroSoftware\\UnbounceSdk\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"AdroSoftware\\UnbounceSdk\\Tests\\": "tests"
},
"files": [
"tests/helpers.php"
]
},
"config": {
"allow-plugins": {
"php-http/discovery": true
},
"sort-packages": true
},
"scripts": {
"check": [
"@phpunit",
"@phpstan",
"@cscheck"
],
"githooks": [
"@pre-commit",
"@pre-push"
],
"pre-commit": "cp ./.githooks/pre-commit ./.git/hooks/pre-commit && chmod a+x ./.git/hooks/pre-commit",
"pre-push": "cp ./.githooks/pre-push ./.git/hooks/pre-push && chmod a+x ./.git/hooks/pre-push",
"phpunit": "./vendor/bin/phpunit",
"cscheck": "./vendor/bin/phpcs",
"csfix": "./vendor/bin/phpcbf",
"phpstan": "./vendor/bin/phpstan analyse -c phpstan.neon",
"coverage": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-html ./.phpunit.cache/logs/html && chmod a+x ./coverage && ./coverage"
}
}
Loading

0 comments on commit 39f93cf

Please sign in to comment.