@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** @test */ |
33 | 33 | public function it_returns_null_in_callback_if_could_not_apply_promocode() |
34 | 34 | { |
35 | - $this->user->applyCode('INVALID-CODE', function ($applyCode) { |
|
35 | + $this->user->applyCode('INVALID-CODE', function($applyCode) { |
|
36 | 36 | $this->assertNull($applyCode); |
37 | 37 | }); |
38 | 38 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $this->assertCount(1, $promocodes); |
93 | 93 | |
94 | - $this->user->applyCode($promocode['code'], function ($appliedPromocode) { |
|
94 | + $this->user->applyCode($promocode['code'], function($appliedPromocode) { |
|
95 | 95 | $this->assertTrue($appliedPromocode instanceof Promocode); |
96 | 96 | }); |
97 | 97 | } |
@@ -14,14 +14,14 @@ discard block |
||
14 | 14 | public function boot() |
15 | 15 | { |
16 | 16 | $this->publishes([ |
17 | - __DIR__ . '/../config/promocodes.php' => config_path('promocodes.php'), |
|
17 | + __DIR__.'/../config/promocodes.php' => config_path('promocodes.php'), |
|
18 | 18 | ]); |
19 | 19 | |
20 | 20 | if (!class_exists('CreatePromocodesTable')) { |
21 | 21 | $timestamp = date('Y_m_d_His', time()); |
22 | 22 | |
23 | 23 | $this->publishes([ |
24 | - __DIR__ . '/../migrations/create_promocodes_table.php.stub' => database_path("/migrations/{$timestamp}_create_promocodes_table.php"), |
|
24 | + __DIR__.'/../migrations/create_promocodes_table.php.stub' => database_path("/migrations/{$timestamp}_create_promocodes_table.php"), |
|
25 | 25 | ], 'migrations'); |
26 | 26 | } |
27 | 27 | } |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | public function register() |
35 | 35 | { |
36 | 36 | $this->mergeConfigFrom( |
37 | - __DIR__ . '/../config/promocodes.php', 'promocodes' |
|
37 | + __DIR__.'/../config/promocodes.php', 'promocodes' |
|
38 | 38 | ); |
39 | 39 | |
40 | - $this->app->singleton('promocodes', function ($app) { |
|
40 | + $this->app->singleton('promocodes', function($app) { |
|
41 | 41 | return new Promocodes(); |
42 | 42 | }); |
43 | 43 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public function up() |
14 | 14 | { |
15 | - Schema::create('promocodes', function (Blueprint $table) { |
|
15 | + Schema::create('promocodes', function(Blueprint $table) { |
|
16 | 16 | $table->increments('id'); |
17 | 17 | |
18 | 18 | $table->string('code', 32)->unique(); |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $table->timestamp('expires_at')->nullable(); |
26 | 26 | }); |
27 | 27 | |
28 | - Schema::create('promocode_user', function (Blueprint $table) { |
|
28 | + Schema::create('promocode_user', function(Blueprint $table) { |
|
29 | 29 | $table->unsignedBigInteger('user_id'); |
30 | 30 | $table->unsignedBigInteger('promocode_id'); |
31 | 31 |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | $this->codes = Promocode::pluck('code')->toArray(); |
49 | 49 | $this->length = substr_count(config('promocodes.mask'), '*'); |
50 | 50 | |
51 | - $this->prefix = (bool)config('promocodes.prefix') |
|
52 | - ? config('promocodes.prefix') . config('promocodes.separator') |
|
51 | + $this->prefix = (bool) config('promocodes.prefix') |
|
52 | + ? config('promocodes.prefix').config('promocodes.separator') |
|
53 | 53 | : ''; |
54 | 54 | |
55 | - $this->suffix = (bool)config('promocodes.suffix') |
|
56 | - ? config('promocodes.separator') . config('promocodes.suffix') |
|
55 | + $this->suffix = (bool) config('promocodes.suffix') |
|
56 | + ? config('promocodes.separator').config('promocodes.suffix') |
|
57 | 57 | : ''; |
58 | 58 | } |
59 | 59 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | if (Promocode::insert($records)) { |
121 | - return collect($records)->map(function ($record) { |
|
121 | + return collect($records)->map(function($record) { |
|
122 | 122 | $record['data'] = json_decode($record['data'], true); |
123 | 123 | |
124 | 124 | return $record; |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | */ |
341 | 341 | public function clearRedundant() |
342 | 342 | { |
343 | - Promocode::all()->each(function (Promocode $promocode) { |
|
343 | + Promocode::all()->each(function(Promocode $promocode) { |
|
344 | 344 | if ($promocode->isExpired() || ($promocode->isDisposable() && $promocode->users()->exists()) || $promocode->isOverAmount()) { |
345 | 345 | $promocode->users()->detach(); |
346 | 346 | $promocode->delete(); |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | */ |
356 | 356 | public function all() |
357 | 357 | { |
358 | - return Promocode::all()->filter(function (Promocode $promocode) { |
|
358 | + return Promocode::all()->filter(function(Promocode $promocode) { |
|
359 | 359 | return !$promocode->isExpired() && !($promocode->isDisposable() && $promocode->users()->exists()) && !$promocode->isOverAmount(); |
360 | 360 | }); |
361 | 361 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * Your code will be validated to be unique for one request. |
254 | 254 | * |
255 | 255 | * @param $collection |
256 | - * @param $new |
|
256 | + * @param string $new |
|
257 | 257 | * |
258 | 258 | * @return bool |
259 | 259 | */ |
@@ -288,7 +288,6 @@ discard block |
||
288 | 288 | /** |
289 | 289 | * Get custom set data value |
290 | 290 | * |
291 | - * @param null|array $data |
|
292 | 291 | * @return null|array |
293 | 292 | */ |
294 | 293 | public function getData($request) |
@@ -456,7 +455,7 @@ discard block |
||
456 | 455 | * |
457 | 456 | * @param string $code |
458 | 457 | * |
459 | - * @return bool|Promocode |
|
458 | + * @return Promocode |
|
460 | 459 | * @throws InvalidPromocodeException |
461 | 460 | */ |
462 | 461 | public function check($code) |
@@ -5,7 +5,6 @@ |
||
5 | 5 | use Promocodes; |
6 | 6 | use Gabievi\Promocodes\Models\Promocode; |
7 | 7 | use Gabievi\Promocodes\Tests\Models\User; |
8 | -use Gabievi\Promocodes\Exceptions\InvalidPromocodeException; |
|
9 | 8 | |
10 | 9 | class CheckPromocodeValidationTest extends TestCase |
11 | 10 | { |