Skip to content

Commit b682bef

Browse files
committed
Remove helper usage
1 parent 99d88e5 commit b682bef

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/HasSequence.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Bnb\Laravel\Sequence\Jobs\UpdateSequence;
88
use DB;
99
use Illuminate\Database\Eloquent\SoftDeletes;
10+
use Illuminate\Support\Str;
1011

1112
trait HasSequence
1213
{
@@ -65,7 +66,7 @@ protected function canGenerateSequenceNumber($name)
6566
{
6667
$authorized = true;
6768

68-
if (method_exists($this, $method = 'canGenerate' . ucfirst(camel_case($name)) . 'Sequence')) {
69+
if (method_exists($this, $method = 'canGenerate' . ucfirst(Str::camel($name)) . 'Sequence')) {
6970
$authorized = ! ! $this->{$method}();
7071
}
7172

@@ -94,7 +95,7 @@ public function generateSequenceNumber($name = null, $save = true)
9495

9596
if ($saved = $this->save()) {
9697
collect($generated)->each(function ($name) {
97-
$this->fireModelEvent(sprintf('sequence_%s_generated', studly_case($name)), false);
98+
$this->fireModelEvent(sprintf('sequence_%s_generated', Str::studly($name)), false);
9899
});
99100
}
100101

@@ -108,7 +109,7 @@ public function generateSequenceNumber($name = null, $save = true)
108109
if ($this->canGenerateSequenceNumber($name)) {
109110
$sequence = null;
110111

111-
if (method_exists($this, $method = 'is' . ucfirst(camel_case($name)) . 'GapFilling') && $this->{$method}()) {
112+
if (method_exists($this, $method = 'is' . ucfirst(Str::camel($name)) . 'GapFilling') && $this->{$method}()) {
112113
$start = $this->generateSequenceStartValue($name) - 1;
113114

114115
$sequence = DB::selectOne(DB::raw(<<<SQL
@@ -141,7 +142,7 @@ public function generateSequenceNumber($name = null, $save = true)
141142

142143
$next = intval($next);
143144

144-
if (method_exists($this, $method = 'format' . ucfirst(camel_case($name)) . 'Sequence')) {
145+
if (method_exists($this, $method = 'format' . ucfirst(Str::camel($name)) . 'Sequence')) {
145146
$next = $this->{$method}($next, $sequence->last_sequence_value);
146147

147148
if ( ! preg_match('/^\d{1,10}$/', $next)) {
@@ -157,7 +158,7 @@ public function generateSequenceNumber($name = null, $save = true)
157158

158159
if ($save) {
159160
if ($this->save()) {
160-
$this->fireModelEvent(sprintf('sequence_%s_generated', studly_case($name)), false);
161+
$this->fireModelEvent(sprintf('sequence_%s_generated', Str::studly($name)), false);
161162
}
162163
}
163164

@@ -176,7 +177,7 @@ public function generateSequenceNumber($name = null, $save = true)
176177
*/
177178
public static function sequenceGenerated($name, $callback)
178179
{
179-
static::registerModelEvent(sprintf('sequence_%s_generated', studly_case($name)), $callback);
180+
static::registerModelEvent(sprintf('sequence_%s_generated', Str::studly($name)), $callback);
180181
}
181182

182183

@@ -189,7 +190,7 @@ protected function generateSequenceStartValue($name)
189190
{
190191
$defaultStart = config('sequence.start', 1);
191192

192-
if (method_exists($this, $method = 'get' . ucfirst(camel_case($name)) . 'StartValue')) {
193+
if (method_exists($this, $method = 'get' . ucfirst(Str::camel($name)) . 'StartValue')) {
193194
$defaultStart = $this->{$method}();
194195
}
195196

@@ -205,7 +206,7 @@ protected function handleSoftDeletedSequence($name, $save = true)
205206
get_class($this)
206207
));
207208

208-
$isGapFilling = method_exists($this, $method = 'is' . ucfirst(camel_case($name)) . 'GapFilling') && $this->{$method}();
209+
$isGapFilling = method_exists($this, $method = 'is' . ucfirst(Str::camel($name)) . 'GapFilling') && $this->{$method}();
209210

210211
if ($this->exists() && $isSoftDelete && $isGapFilling && ! is_null($this->{$this->getDeletedAtColumn()}) && $this->{$name}) {
211212
$this->{$name} = null;

tests/SequenceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private function formatSequence($date, $next)
2626
}
2727

2828

29-
protected function setUp()
29+
protected function setUp(): void
3030
{
3131
if ( ! $this->app) {
3232
$this->refreshApplication();

0 commit comments

Comments
 (0)