Skip to content

Commit

Permalink
Removed deprecated global helper array and str. Replaced with \Illumi…
Browse files Browse the repository at this point in the history
…nate\Support classes (#60)
  • Loading branch information
henryavila authored and jafar690 committed Oct 14, 2019
1 parent afbe30a commit b4819e5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace BeyondCode\ErdGenerator;

use Illuminate\Support\Collection;
use Illuminate\Support\Str;

class Model
{
Expand Down Expand Up @@ -30,7 +31,7 @@ public function getModel()
*/
public function getNodeName()
{
return str_replace('-', '', str_slug($this->model));
return str_replace('-', '', Str::slug($this->model));
}

/**
Expand All @@ -48,4 +49,4 @@ public function getRelations()
{
return $this->relations;
}
}
}
5 changes: 3 additions & 2 deletions src/ModelRelation.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

namespace BeyondCode\ErdGenerator;
use Illuminate\Support\Str;

class ModelRelation
{
Expand Down Expand Up @@ -32,7 +33,7 @@ public function getModel()
*/
public function getModelNodeName()
{
return str_slug($this->model);
return Str::slug($this->model);
}

/**
Expand Down Expand Up @@ -66,4 +67,4 @@ public function getName()
{
return $this->name;
}
}
}
6 changes: 4 additions & 2 deletions src/RelationFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use Illuminate\Support\Collection;
use ReflectionClass;
use ReflectionMethod;
use Illuminate\Support\Arr;


class RelationFinder
{
Expand Down Expand Up @@ -40,7 +42,7 @@ public function getModelRelations(string $model)

$relations = $relations->filter();

if ($ignoreRelations = array_get(config('erd-generator.ignore', []),$model))
if ($ignoreRelations = Arr::get(config('erd-generator.ignore', []),$model))
{
$relations = $relations->diffKeys(array_flip($ignoreRelations));
}
Expand Down Expand Up @@ -96,5 +98,5 @@ protected function getRelationshipFromMethodAndModel(ReflectionMethod $method, s
} catch (\Throwable $e) {}
return null;
}

}
6 changes: 4 additions & 2 deletions tests/GetModelRelationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use BeyondCode\ErdGenerator\Tests\Models\Comment;
use BeyondCode\ErdGenerator\Tests\Models\Post;
use BeyondCode\ErdGenerator\Tests\Models\User;
use Illuminate\Support\Arr;


class GetModelRelationsTest extends TestCase
{
Expand Down Expand Up @@ -63,7 +65,7 @@ public function it_will_ignore_a_relation_if_it_is_excluded_on_config()
$relations = $finder->getModelRelations(User::class);

$this->assertCount(2, $relations);
$this->assertNull(array_get($relations, 'posts'));
$this->assertNull(Arr::get($relations, 'posts'));
}

}
}

0 comments on commit b4819e5

Please sign in to comment.