Skip to content

Commit b18d1ea

Browse files
Merge pull request #26 from guiwoda/remove-illuminate-dependency
Removed illuminate/support in favor of doctrine/inflector
2 parents 17f8037 + 5b98347 commit b18d1ea

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"require": {
2626
"php": ">=5.5.0",
2727
"doctrine/orm": "2.5.*",
28-
"illuminate/support": "~5.1"
28+
"doctrine/inflector": "^1.1"
2929
},
3030
"require-dev": {
3131
"phpunit/phpunit": "~4.0",

src/Builders/Traits/Relations.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace LaravelDoctrine\Fluent\Builders\Traits;
44

5-
use Illuminate\Support\Str;
5+
use Doctrine\Common\Inflector\Inflector;
66
use LaravelDoctrine\Fluent\Buildable;
77
use LaravelDoctrine\Fluent\Relations\ManyToMany;
88
use LaravelDoctrine\Fluent\Relations\ManyToOne;
@@ -165,7 +165,9 @@ public function addRelation(Relation $relation, callable $callback = null)
165165
*/
166166
protected function guessSingularField($entity, $field = null)
167167
{
168-
return $field ?: Str::camel(class_basename($entity));
168+
return $field ?: Inflector::singularize(
169+
lcfirst(basename(str_replace('\\', '/', $entity)))
170+
);
169171
}
170172

171173
/**
@@ -176,7 +178,7 @@ protected function guessSingularField($entity, $field = null)
176178
*/
177179
protected function guessPluralField($entity, $field = null)
178180
{
179-
return $field ?: Str::plural($this->guessSingularField($entity));
181+
return $field ?: Inflector::pluralize($this->guessSingularField($entity));
180182
}
181183

182184
/**

src/Relations/AbstractRelation.php

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

55
use BadMethodCallException;
6+
use Doctrine\Common\Inflector\Inflector;
67
use Doctrine\ORM\Mapping\Builder\AssociationBuilder;
78
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
89
use Doctrine\ORM\Mapping\NamingStrategy;
@@ -84,7 +85,7 @@ abstract protected function createAssociation(ClassMetadataBuilder $builder, $re
8485
public function cascade(array $cascade)
8586
{
8687
foreach ($cascade as $name) {
87-
$method = 'cascade' . studly_case(strtolower($name));
88+
$method = 'cascade' . Inflector::classify(strtolower($name));
8889

8990
if (!method_exists($this->association, $method)) {
9091
throw new InvalidArgumentException('Cascade [' . $name . '] does not exist');
@@ -103,7 +104,7 @@ public function cascade(array $cascade)
103104
*/
104105
public function fetch($strategy)
105106
{
106-
$method = 'fetch' . studly_case(strtolower($strategy));
107+
$method = 'fetch' . Inflector::classify(strtolower($strategy));
107108

108109
if (!method_exists($this->association, $method)) {
109110
throw new InvalidArgumentException('Fetch [' . $strategy . '] does not exist');

0 commit comments

Comments
 (0)