Skip to content

Commit 083dc37

Browse files
committed
Made uuid generator optional (suggest via composer)
1 parent 059dea7 commit 083dc37

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
"symfony/polyfill-php70": "^1.3",
1818
"symfony/security": "^2.8|^3.0",
1919
"symfony/options-resolver": "^2.8|^3.0",
20-
"ircmaxell/random-lib": "~1.0",
21-
"ramsey/uuid": "^3.6"
20+
"ircmaxell/random-lib": "~1.0"
21+
},
22+
"suggest": {
23+
"ramsey/uuid": "To use the UUID generator you should require this package"
2224
},
2325
"require-dev": {
2426
"phpspec/phpspec": "~2.0"

src/Vivait/StringGeneratorBundle/Generator/UuidGenerator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public function __construct()
3838
*/
3939
public function generate()
4040
{
41+
if(!class_exists('Ramsey\Uuid\Uuid')) {
42+
throw new \RuntimeException('For use the UUID generator you should setup the ramsey/uuid package');
43+
}
44+
4145
switch($this->version) {
4246
case 1:
4347
return Uuid::uuid1()->toString();

0 commit comments

Comments
 (0)