Skip to content

Commit b4819e5

Browse files
henryavilajafar690
authored andcommitted
Removed deprecated global helper array and str. Replaced with \Illuminate\Support classes (#60)
1 parent afbe30a commit b4819e5

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

src/Model.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace BeyondCode\ErdGenerator;
44

55
use Illuminate\Support\Collection;
6+
use Illuminate\Support\Str;
67

78
class Model
89
{
@@ -30,7 +31,7 @@ public function getModel()
3031
*/
3132
public function getNodeName()
3233
{
33-
return str_replace('-', '', str_slug($this->model));
34+
return str_replace('-', '', Str::slug($this->model));
3435
}
3536

3637
/**
@@ -48,4 +49,4 @@ public function getRelations()
4849
{
4950
return $this->relations;
5051
}
51-
}
52+
}

src/ModelRelation.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
namespace BeyondCode\ErdGenerator;
4+
use Illuminate\Support\Str;
45

56
class ModelRelation
67
{
@@ -32,7 +33,7 @@ public function getModel()
3233
*/
3334
public function getModelNodeName()
3435
{
35-
return str_slug($this->model);
36+
return Str::slug($this->model);
3637
}
3738

3839
/**
@@ -66,4 +67,4 @@ public function getName()
6667
{
6768
return $this->name;
6869
}
69-
}
70+
}

src/RelationFinder.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Illuminate\Support\Collection;
99
use ReflectionClass;
1010
use ReflectionMethod;
11+
use Illuminate\Support\Arr;
12+
1113

1214
class RelationFinder
1315
{
@@ -40,7 +42,7 @@ public function getModelRelations(string $model)
4042

4143
$relations = $relations->filter();
4244

43-
if ($ignoreRelations = array_get(config('erd-generator.ignore', []),$model))
45+
if ($ignoreRelations = Arr::get(config('erd-generator.ignore', []),$model))
4446
{
4547
$relations = $relations->diffKeys(array_flip($ignoreRelations));
4648
}
@@ -96,5 +98,5 @@ protected function getRelationshipFromMethodAndModel(ReflectionMethod $method, s
9698
} catch (\Throwable $e) {}
9799
return null;
98100
}
99-
101+
100102
}

tests/GetModelRelationsTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use BeyondCode\ErdGenerator\Tests\Models\Comment;
99
use BeyondCode\ErdGenerator\Tests\Models\Post;
1010
use BeyondCode\ErdGenerator\Tests\Models\User;
11+
use Illuminate\Support\Arr;
12+
1113

1214
class GetModelRelationsTest extends TestCase
1315
{
@@ -63,7 +65,7 @@ public function it_will_ignore_a_relation_if_it_is_excluded_on_config()
6365
$relations = $finder->getModelRelations(User::class);
6466

6567
$this->assertCount(2, $relations);
66-
$this->assertNull(array_get($relations, 'posts'));
68+
$this->assertNull(Arr::get($relations, 'posts'));
6769
}
6870

69-
}
71+
}

0 commit comments

Comments
 (0)