-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
571 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
new_version: | ||
description: 'New version' | ||
required: true | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout master | ||
uses: actions/checkout@v1 | ||
with: | ||
ref: 'master' | ||
- name: Checkout develop | ||
uses: actions/checkout@v1 | ||
with: | ||
ref: 'develop' | ||
clean: false | ||
- name: Install git-flow | ||
run: sudo apt-get install git-flow -y | ||
- name: Configure commiter | ||
run: | | ||
git config --local user.email "${{ secrets.WORKER_EMAIL }}" | ||
git config --local user.name "${{ secrets.WORKER_NAME }}" | ||
- name: Init git-flow | ||
run: git flow init -d | ||
- name: Start release | ||
run: git flow release start ${{ github.event.inputs.new_version }} | ||
- name: Replace 1.0.0 tags with new version number | ||
uses: jacobtomlinson/gha-find-replace@master | ||
with: | ||
find: "(?i)\\[Next\\]" | ||
replace: "${{ github.event.inputs.new_version }}" | ||
- name: Commit version bump | ||
run: git commit -am "Version bump" | ||
- name: Finish release | ||
run: git flow release finish ${{ github.event.inputs.new_version }} -m "v${{ github.event.inputs.new_version }}" | ||
- name: Push develop and tags | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.WORKER_TOKEN }} | ||
branch: 'develop' | ||
- name: Push master | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.WORKER_TOKEN }} | ||
branch: 'master' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Stable | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
|
||
# Release on GitHub | ||
github-release: | ||
name: Release on GitHub | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Parse changelog | ||
run: | | ||
START="## ${{ steps.vars.outputs.version }}" | ||
END="## [0-9]+.[0-9]+.[0-9]+|\$" | ||
grep -oPz "(?s)${START}.*?\n\K.*?(?=${END})" CHANGELOG.md > changelog.txt | ||
truncate -s-3 changelog.txt | ||
sed -i '1d' changelog.txt | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
body_path: changelog.txt | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
## 1.0.0 | ||
|
||
Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Casegnostic | ||
|
||
[![BracketSpace Micropackage](https://img.shields.io/badge/BracketSpace-Micropackage-brightgreen)](https://bracketspace.com) | ||
[![Latest Stable Version](https://poser.pugx.org/micropackage/dochooks/v/stable)](https://packagist.org/packages/micropackage/dochooks) | ||
[![PHP from Packagist](https://img.shields.io/packagist/php-v/micropackage/dochooks.svg)](https://packagist.org/packages/micropackage/dochooks) | ||
[![Total Downloads](https://poser.pugx.org/micropackage/dochooks/downloads)](https://packagist.org/packages/micropackage/dochooks) | ||
[![License](https://poser.pugx.org/micropackage/dochooks/license)](https://packagist.org/packages/micropackage/dochooks) | ||
|
||
<p align="center"> | ||
<img src="https://bracketspace.com/extras/micropackage/micropackage-small.png" alt="Micropackage logo"/> | ||
</p> | ||
|
||
## 🧬 About Casegnostic | ||
|
||
Package that simplifies transition from one coding standard to other, namely from snake_case to camelCase or vice-versa. | ||
|
||
When you're about to break compatibility by changing method name from something_important() to somethingImportant() you can simply attach the trait. | ||
|
||
```php | ||
use Micropackage\Casegnostic\Casegnostic; | ||
|
||
class Example | ||
{ | ||
use Casegnostic; | ||
|
||
public function somethingImportant() | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
$x = new Example(); | ||
|
||
// That works as expected: | ||
$x->somethingImportant(); | ||
|
||
// But that works too! 🤯 | ||
$x->something_important(); | ||
``` | ||
|
||
## 💾 Installation | ||
|
||
``` bash | ||
composer require micropackage/casegnostic | ||
``` | ||
|
||
## 🕹 Usage | ||
|
||
Simply attach the trait to your class. | ||
|
||
```php | ||
use Micropackage\Casegnostic\Casegnostic; | ||
|
||
class Example | ||
{ | ||
use Casegnostic; | ||
} | ||
``` | ||
|
||
## 📦 About the Micropackage project | ||
|
||
Micropackages - as the name suggests - are micro packages with a tiny bit of reusable code, helpful particularly in WordPress development. | ||
|
||
The aim is to have multiple packages which can be put together to create something bigger by defining only the structure. | ||
|
||
Micropackages are maintained by [BracketSpace](https://bracketspace.com). | ||
|
||
## 📖 Changelog | ||
|
||
[See the changelog file](./CHANGELOG.md). | ||
|
||
## 📃 License | ||
|
||
GNU General Public License (GPL) v3.0. See the [LICENSE](./LICENSE) file for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Casegnostic | ||
* | ||
* @package micropackage/casegnostic | ||
*/ | ||
|
||
namespace Micropackage\Casegnostic; | ||
|
||
use Micropackage\Casegnostic\Helpers\CaseHelper; | ||
|
||
/** | ||
* Casegnostic trait | ||
*/ | ||
trait Casegnostic | ||
{ | ||
/** | ||
* @param string $name | ||
* @return mixed|void | ||
* @throws \Exception | ||
*/ | ||
public function __get(string $name) | ||
{ | ||
if (CaseHelper::isSnake($name)) { | ||
if (property_exists($this, CaseHelper::toCamel($name))) { | ||
return $this->{CaseHelper::toCamel($name)}; | ||
} | ||
} | ||
|
||
if (!CaseHelper::isCamel($name)) { | ||
return; | ||
} | ||
|
||
if (property_exists($this, CaseHelper::toSnake($name))) { | ||
return $this->{CaseHelper::toSnake($name)}; | ||
} | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* @param mixed $value | ||
* @return void | ||
* @throws \Exception | ||
*/ | ||
public function __set(string $name, $value) | ||
{ | ||
if (CaseHelper::isSnake($name)) { | ||
if (property_exists($this, CaseHelper::toCamel($name))) { | ||
$this->{CaseHelper::toCamel($name)} = $value; | ||
} | ||
} | ||
|
||
if (!CaseHelper::isCamel($name)) { | ||
return; | ||
} | ||
|
||
if (!property_exists($this, CaseHelper::toSnake($name))) { | ||
return; | ||
} | ||
|
||
$this->{CaseHelper::toSnake($name)} = $value; | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* @param array<mixed> $arguments | ||
* @return mixed | ||
* @throws \Exception | ||
*/ | ||
public function __call(string $name, array $arguments) | ||
{ | ||
if (CaseHelper::isSnake($name)) { | ||
if (method_exists($this, CaseHelper::toCamel($name))) { | ||
return $this->{CaseHelper::toCamel($name)}(...$arguments); | ||
} | ||
} | ||
|
||
if (CaseHelper::isCamel($name)) { | ||
if (method_exists($this, CaseHelper::toSnake($name))) { | ||
return $this->{CaseHelper::toSnake($name)}(...$arguments); | ||
} | ||
} | ||
|
||
throw new \BadMethodCallException("Method \"{$name}\" does not exist."); | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* @param array<mixed> $arguments | ||
* @return mixed | ||
* @throws \Exception | ||
*/ | ||
public static function __callStatic(string $name, array $arguments) | ||
{ | ||
if (CaseHelper::isSnake($name)) { | ||
if (method_exists(self::class, CaseHelper::toCamel($name))) { | ||
return static::{CaseHelper::toCamel($name)}(...$arguments); | ||
} | ||
} | ||
|
||
if (CaseHelper::isCamel($name)) { | ||
if (method_exists(self::class, CaseHelper::toSnake($name))) { | ||
return static::{CaseHelper::toSnake($name)}(...$arguments); | ||
} | ||
} | ||
|
||
throw new \BadMethodCallException("Static method \"{$name}\" does not exist."); | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* @return bool | ||
* @throws \Exception | ||
*/ | ||
public function __isset(string $name) | ||
{ | ||
if (CaseHelper::isSnake($name)) { | ||
return isset($this->{CaseHelper::toCamel($name)}); | ||
} | ||
|
||
if (CaseHelper::isCamel($name)) { | ||
return isset($this->{CaseHelper::toSnake($name)}); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* @return void | ||
* @throws \Exception | ||
*/ | ||
public function __unset(string $name) | ||
{ | ||
if (CaseHelper::isSnake($name)) { | ||
if (isset($this->{CaseHelper::toCamel($name)})) { | ||
unset($this->{CaseHelper::toCamel($name)}); | ||
} | ||
} | ||
|
||
if (CaseHelper::isCamel($name)) { | ||
if (isset($this->{CaseHelper::toSnake($name)})) { | ||
unset($this->{CaseHelper::toSnake($name)}); | ||
} | ||
} | ||
|
||
throw new \InvalidArgumentException("Can't find value \"{$name}\" to unset."); | ||
} | ||
} |
Oops, something went wrong.