mirror of
https://github.com/michaelachrisco/ReadOnlyTraitLaravel.git
synced 2024-10-31 21:33:23 -07:00
Add PHP-CS-Fixer to linting process and Travis.
This commit is contained in:
parent
07453dad8e
commit
5a43121592
5 changed files with 67 additions and 44 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@ composer.phar
|
||||||
composer.lock
|
composer.lock
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/.idea
|
/.idea
|
||||||
|
.php_cs.cache
|
||||||
|
|
|
@ -5,7 +5,6 @@ php:
|
||||||
- 5.5
|
- 5.5
|
||||||
- 5.6
|
- 5.6
|
||||||
- 7.1
|
- 7.1
|
||||||
- hhvm
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
|
@ -22,4 +21,6 @@ install:
|
||||||
- if [[ $setup = 'stable' ]]; then travis_retry composer update --prefer-source --no-interaction --prefer-stable; fi
|
- if [[ $setup = 'stable' ]]; then travis_retry composer update --prefer-source --no-interaction --prefer-stable; fi
|
||||||
- if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-source --no-interaction --prefer-lowest --prefer-stable; fi
|
- if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-source --no-interaction --prefer-lowest --prefer-stable; fi
|
||||||
|
|
||||||
script: ./vendor/bin/kahlan -reporter=verbose
|
script:
|
||||||
|
- ./vendor/bin/kahlan -reporter=verbose
|
||||||
|
- ./vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix src/
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"kahlan/kahlan": "^2.4",
|
"kahlan/kahlan": "^2.4",
|
||||||
"illuminate/database": ">=5.2.0"
|
"illuminate/database": ">=5.2.0",
|
||||||
|
"friendsofphp/php-cs-fixer": "^2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
namespace MichaelAChrisco\ReadOnly;
|
namespace MichaelAChrisco\ReadOnly;
|
||||||
use RuntimeException;
|
|
||||||
|
|
||||||
class ReadOnlyException extends RuntimeException{}
|
class ReadOnlyException extends \RuntimeException
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
namespace MichaelAChrisco\ReadOnly;
|
namespace MichaelAChrisco\ReadOnly;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use MichaelAChrisco\ReadOnly\ReadOnlyException;
|
use MichaelAChrisco\ReadOnly\ReadOnlyException;
|
||||||
|
|
||||||
trait ReadOnlyTrait {
|
trait ReadOnlyTrait
|
||||||
|
{
|
||||||
static function readOnly($class){
|
public static function readOnly($class)
|
||||||
|
{
|
||||||
throw new ReadOnlyException("Not allowed to persist changes in read-only model {$class}");
|
throw new ReadOnlyException("Not allowed to persist changes in read-only model {$class}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +17,8 @@ trait ReadOnlyTrait {
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static function create(array $attributes = []){
|
public static function create(array $attributes = [])
|
||||||
|
{
|
||||||
ReadOnlyTrait::readOnly(get_called_class());
|
ReadOnlyTrait::readOnly(get_called_class());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +28,8 @@ trait ReadOnlyTrait {
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static function forceCreate(array $attributes){
|
public static function forceCreate(array $attributes)
|
||||||
|
{
|
||||||
ReadOnlyTrait::readOnly(get_called_class());
|
ReadOnlyTrait::readOnly(get_called_class());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +39,8 @@ trait ReadOnlyTrait {
|
||||||
* @param array $options
|
* @param array $options
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function save(array $options = []){
|
public function save(array $options = [])
|
||||||
|
{
|
||||||
ReadOnlyTrait::readOnly(get_called_class());
|
ReadOnlyTrait::readOnly(get_called_class());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +51,8 @@ trait ReadOnlyTrait {
|
||||||
* @param $options
|
* @param $options
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function update(array $attributes = [], array $options = []){
|
public function update(array $attributes = [], array $options = [])
|
||||||
|
{
|
||||||
ReadOnlyTrait::readOnly(get_called_class());
|
ReadOnlyTrait::readOnly(get_called_class());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +62,8 @@ trait ReadOnlyTrait {
|
||||||
* @param array $arr
|
* @param array $arr
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static function firstOrCreate(array $arr){
|
public static function firstOrCreate(array $arr)
|
||||||
|
{
|
||||||
ReadOnlyTrait::readOnly(get_called_class());
|
ReadOnlyTrait::readOnly(get_called_class());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +73,8 @@ trait ReadOnlyTrait {
|
||||||
* @param array $arr
|
* @param array $arr
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static function firstOrNew(array $arr){
|
public static function firstOrNew(array $arr)
|
||||||
|
{
|
||||||
ReadOnlyTrait::readOnly(get_called_class());
|
ReadOnlyTrait::readOnly(get_called_class());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +83,8 @@ trait ReadOnlyTrait {
|
||||||
* @method delete
|
* @method delete
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function delete(){
|
public function delete()
|
||||||
|
{
|
||||||
ReadOnlyTrait::readOnly(get_called_class());
|
ReadOnlyTrait::readOnly(get_called_class());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +94,8 @@ trait ReadOnlyTrait {
|
||||||
* @param mixed $ids
|
* @param mixed $ids
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static function destroy($ids){
|
public static function destroy($ids)
|
||||||
|
{
|
||||||
ReadOnlyTrait::readOnly(get_called_class());
|
ReadOnlyTrait::readOnly(get_called_class());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +104,8 @@ trait ReadOnlyTrait {
|
||||||
* @method restore
|
* @method restore
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function restore(){
|
public function restore()
|
||||||
|
{
|
||||||
ReadOnlyTrait::readOnly(get_called_class());
|
ReadOnlyTrait::readOnly(get_called_class());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +114,8 @@ trait ReadOnlyTrait {
|
||||||
* @method forceDelete
|
* @method forceDelete
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function forceDelete(){
|
public function forceDelete()
|
||||||
|
{
|
||||||
ReadOnlyTrait::readOnly(get_called_class());
|
ReadOnlyTrait::readOnly(get_called_class());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +124,8 @@ trait ReadOnlyTrait {
|
||||||
* @method performDeleteOnModel
|
* @method performDeleteOnModel
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function performDeleteOnModel(){
|
public function performDeleteOnModel()
|
||||||
|
{
|
||||||
ReadOnlyTrait::readOnly(get_called_class());
|
ReadOnlyTrait::readOnly(get_called_class());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +134,8 @@ trait ReadOnlyTrait {
|
||||||
* @method push
|
* @method push
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function push(){
|
public function push()
|
||||||
|
{
|
||||||
ReadOnlyTrait::readOnly(get_called_class());
|
ReadOnlyTrait::readOnly(get_called_class());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +144,8 @@ trait ReadOnlyTrait {
|
||||||
* @method finishSave
|
* @method finishSave
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function finishSave(array $options){
|
public function finishSave(array $options)
|
||||||
|
{
|
||||||
ReadOnlyTrait::readOnly(get_called_class());
|
ReadOnlyTrait::readOnly(get_called_class());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +154,8 @@ trait ReadOnlyTrait {
|
||||||
* @method performUpdate
|
* @method performUpdate
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function performUpdate(Builder $query, array $options = []){
|
public function performUpdate(Builder $query, array $options = [])
|
||||||
|
{
|
||||||
ReadOnlyTrait::readOnly(get_called_class());
|
ReadOnlyTrait::readOnly(get_called_class());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +164,8 @@ trait ReadOnlyTrait {
|
||||||
* @method touch
|
* @method touch
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function touch(){
|
public function touch()
|
||||||
|
{
|
||||||
ReadOnlyTrait::readOnly(get_called_class());
|
ReadOnlyTrait::readOnly(get_called_class());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +174,8 @@ trait ReadOnlyTrait {
|
||||||
* @method insert
|
* @method insert
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function insert(){
|
public function insert()
|
||||||
|
{
|
||||||
ReadOnlyTrait::readOnly(get_called_class());
|
ReadOnlyTrait::readOnly(get_called_class());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +184,8 @@ trait ReadOnlyTrait {
|
||||||
* @method truncate
|
* @method truncate
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function truncate(){
|
public function truncate()
|
||||||
|
{
|
||||||
ReadOnlyTrait::readOnly(get_called_class());
|
ReadOnlyTrait::readOnly(get_called_class());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue