Skip to content

Commit b1513d2

Browse files
committed
Remove need for Container
1 parent efb3996 commit b1513d2

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
### Changed
6+
- Changed the signature for the Manager class. Remove the requirement for the container to be passed in.
7+
58
## 0.4.6 - 2021-07-28
69

710
### Added

src/Manager.php

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
namespace Torchlight;
77

88
use Illuminate\Contracts\Cache\Repository;
9-
use Illuminate\Contracts\Container\Container;
109
use Illuminate\Support\Arr;
1110
use Illuminate\Support\Facades\Cache;
1211
use Illuminate\Support\Str;
@@ -27,38 +26,45 @@ class Manager
2726
protected $cache;
2827

2928
/**
30-
* @var Container
29+
* @var Client
3130
*/
32-
protected $app;
31+
protected $client;
3332

3433
/**
3534
* @var null|string
3635
*/
3736
protected $environment;
3837

3938
/**
40-
* @param Container $app
39+
* @param Client $client
40+
* @return Manager
4141
*/
42-
public function __construct(Container $app)
42+
public function setClient(Client $client)
4343
{
44-
$this->app = $app;
44+
$this->client = $client;
45+
46+
return $this;
4547
}
4648

4749
/**
48-
* @param $blocks
49-
* @return mixed
50+
* @return Client
5051
*/
51-
public function highlight($blocks)
52+
public function client()
5253
{
53-
return $this->client()->highlight($blocks);
54+
if (!$this->client) {
55+
$this->client = new Client;
56+
}
57+
58+
return $this->client;
5459
}
5560

5661
/**
57-
* @return Client
62+
* @param $blocks
63+
* @return mixed
5864
*/
59-
public function client()
65+
public function highlight($blocks)
6066
{
61-
return $this->app->make(Client::class);
67+
return $this->client()->highlight($blocks);
6268
}
6369

6470
/**

src/TorchlightServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function boot()
2323
public function bindManagerSingleton()
2424
{
2525
$this->app->singleton(Manager::class, function () {
26-
return new Manager($this->app);
26+
return new Manager;
2727
});
2828
}
2929

0 commit comments

Comments
 (0)