-
Notifications
You must be signed in to change notification settings - Fork 40
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
EmadAdly
committed
Feb 14, 2017
0 parents
commit 79a46ea
Showing
9 changed files
with
332 additions
and
0 deletions.
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,4 @@ | ||
/vendor | ||
composer.phar | ||
composer.lock | ||
.DS_Store |
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,83 @@ | ||
# :package_name | ||
|
||
[![Latest Version on Packagist][ico-version]][link-packagist] | ||
[![Software License][ico-license]](LICENSE.md) | ||
[![Build Status][ico-travis]][link-travis] | ||
[![Coverage Status][ico-scrutinizer]][link-scrutinizer] | ||
[![Quality Score][ico-code-quality]][link-code-quality] | ||
[![Total Downloads][ico-downloads]][link-downloads] | ||
|
||
**Note:** Replace ```:author_name``` ```:author_username``` ```:author_website``` ```:author_email``` ```:vendor``` ```:package_name``` ```:package_description``` with their correct values in [README.md](README.md), [CHANGELOG.md](CHANGELOG.md), [CONTRIBUTING.md](CONTRIBUTING.md), [LICENSE.md](LICENSE.md) and [composer.json](composer.json) files, then delete this line. You can run `$ php prefill.php` in the command line to make all replacements at once. Delete the file prefill.php as well. | ||
|
||
This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what | ||
PSRs you support to avoid any confusion with users and contributors. | ||
|
||
## Structure | ||
|
||
If any of the following are applicable to your project, then the directory structure should follow industry best practises by being named the following. | ||
|
||
``` | ||
bin/ | ||
config/ | ||
src/ | ||
tests/ | ||
vendor/ | ||
``` | ||
|
||
|
||
## Install | ||
|
||
Via Composer | ||
|
||
``` bash | ||
$ composer require :vendor/:package_name | ||
``` | ||
|
||
## Usage | ||
|
||
``` php | ||
$skeleton = new League\Skeleton(); | ||
echo $skeleton->echoPhrase('Hello, League!'); | ||
``` | ||
|
||
## Change log | ||
|
||
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. | ||
|
||
## Testing | ||
|
||
``` bash | ||
$ composer test | ||
``` | ||
|
||
## Contributing | ||
|
||
Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details. | ||
|
||
## Security | ||
|
||
If you discover any security related issues, please email :author_email instead of using the issue tracker. | ||
|
||
## Credits | ||
|
||
- [:author_name][link-author] | ||
- [All Contributors][link-contributors] | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. | ||
|
||
[ico-version]: https://img.shields.io/packagist/v/:vendor/:package_name.svg?style=flat-square | ||
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square | ||
[ico-travis]: https://img.shields.io/travis/:vendor/:package_name/master.svg?style=flat-square | ||
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/:vendor/:package_name.svg?style=flat-square | ||
[ico-code-quality]: https://img.shields.io/scrutinizer/g/:vendor/:package_name.svg?style=flat-square | ||
[ico-downloads]: https://img.shields.io/packagist/dt/:vendor/:package_name.svg?style=flat-square | ||
|
||
[link-packagist]: https://packagist.org/packages/:vendor/:package_name | ||
[link-travis]: https://travis-ci.org/:vendor/:package_name | ||
[link-scrutinizer]: https://scrutinizer-ci.com/g/:vendor/:package_name/code-structure | ||
[link-code-quality]: https://scrutinizer-ci.com/g/:vendor/:package_name | ||
[link-downloads]: https://packagist.org/packages/:vendor/:package_name | ||
[link-author]: https://github.com/:author_username | ||
[link-contributors]: ../../contributors |
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,54 @@ | ||
{ | ||
"name": "emadadly/larauuid", | ||
"type": "library", | ||
"description": ":UUID auto generator for Laravel 5", | ||
"keywords": [ | ||
"emadadly", | ||
"larauuid", | ||
"UUID", | ||
"GUID", | ||
"Laravel", | ||
"generator" | ||
], | ||
"homepage": "https://github.com/emadadly/larauuid", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": ":Emad Adly", | ||
"email": ":[email protected]", | ||
"homepage": ":http://devmark.net", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"illuminate/support": "~5.1", | ||
"php" : "~5.6|~7.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit" : "~4.0||~5.0", | ||
"squizlabs/php_codesniffer": "^2.3" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"emadadly\\larauuid\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"emadadly\\larauuid\\": "tests" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "phpunit", | ||
"check-style": "phpcs -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests", | ||
"fix-style": "phpcbf -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests" | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "1.0-dev" | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
} | ||
} |
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,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="../../../vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
> | ||
<testsuites> | ||
<testsuite name="Package Test Suite"> | ||
<directory suffix=".php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
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,19 @@ | ||
<?php | ||
|
||
namespace emadadly\larauuid\Facades; | ||
|
||
use emadadly\larauuid\UUID; | ||
use Illuminate\Support\Facades\Facade; | ||
|
||
class UUID extends Facade | ||
{ | ||
/** | ||
* Get the registered name of the component. | ||
* | ||
* @return string | ||
*/ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return UUID::class; | ||
} | ||
} |
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,53 @@ | ||
<?php | ||
|
||
namespace emadadly\larauuid; | ||
|
||
class UUIDManager | ||
{ | ||
/** | ||
* @type string | ||
*/ | ||
private $uuid; | ||
|
||
public function __construct() | ||
{ | ||
$uuid = $this->generate(); | ||
|
||
$this->uuid = $uuid; | ||
|
||
return $uuid; | ||
} | ||
|
||
/* public function __toString() | ||
{ | ||
return $this->uuid; | ||
}*/ | ||
|
||
|
||
/** | ||
* | ||
* This function will return a UUID | ||
* | ||
* @return type string | ||
*/ | ||
public static function generate() | ||
{ | ||
|
||
mt_srand((double)microtime()*10000); | ||
$charid = strtoupper(md5(uniqid(rand(), true))); | ||
$hyphen = chr(45);// "-" | ||
$uuid = chr(123)// "{" | ||
.substr($charid, 0, 8).$hyphen | ||
.substr($charid, 8, 4).$hyphen | ||
.substr($charid,12, 4).$hyphen | ||
.substr($charid,16, 4).$hyphen | ||
.substr($charid,20,12) | ||
.chr(125);// "}" | ||
|
||
$uuid = str_replace('{', '' , $uuid); | ||
$uuid = str_replace('}', '' , $uuid); | ||
|
||
return $uuid; | ||
|
||
} | ||
} |
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,18 @@ | ||
<?php | ||
namespace emadadly\larauuid; | ||
|
||
use emadadly\larauuid\UUIDManager; | ||
|
||
trait Uuids | ||
{ | ||
/** | ||
* Boot function from laravel. | ||
*/ | ||
protected static function boot() | ||
{ | ||
parent::boot(); | ||
static::creating(function ($model) { | ||
$model->{$model->getKeyName()} = UUIDManager::generate(); | ||
}); | ||
} | ||
} |
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,73 @@ | ||
<?php | ||
|
||
namespace emadadly\larauuid; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
use Illuminate\Routing\Router; | ||
|
||
class larauuidServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Indicates if loading of the provider is deferred. | ||
* | ||
* @var bool | ||
*/ | ||
protected $defer = false; | ||
|
||
/** | ||
* Perform post-registration booting of services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
|
||
|
||
|
||
// use this if your package needs a config file | ||
// $this->publishes([ | ||
// __DIR__.'/config/config.php' => config_path('larauuid.php'), | ||
// ]); | ||
|
||
// use the vendor configuration file as fallback | ||
// $this->mergeConfigFrom( | ||
// __DIR__.'/config/config.php', 'larauuid' | ||
// ); | ||
} | ||
|
||
|
||
|
||
/** | ||
* Register any package services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->app->singleton(UUIDManager::class, function () { | ||
return new UUIDManager(); | ||
}); | ||
/* $this->app->bind('larauuid',function($app){ | ||
return new UUID; | ||
});*/ | ||
|
||
/* $this->app->singleton(UuidService::class, function($app){ | ||
return new UuidService; | ||
});*/ | ||
// use this if your package has a config file | ||
// config([ | ||
// 'config/larauuid.php', | ||
// ]); | ||
/* $this->app['guid'] = $this->app->share(function($app) { | ||
return new GUID; | ||
});*/ | ||
/* $this->app->booting(function() { | ||
$loader = \Illuminate\Foundation\AliasLoader::getInstance(); | ||
$loader->alias('UUID', 'emadadly\larauuid\Facades\UUID'); | ||
});*/ | ||
} | ||
|
||
|
||
|
||
|
||
} |
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,10 @@ | ||
<?php | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class DemoTest extends TestCase | ||
{ | ||
public function testSomethingIsTrue() | ||
{ | ||
$this->assertTrue(true); | ||
} | ||
} |