Skip to content

Commit e61ca72

Browse files
morrislaptopjenssegers
authored andcommitted
Remove dependency on Laravel Application (#948)
* Remove dependency on Laravel Application * styleci
1 parent c64dc03 commit e61ca72

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Jenssegers/Mongodb/Query/Builder.php

+15-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,21 @@ public function __construct(Connection $connection, Processor $processor)
103103
$this->grammar = new Grammar;
104104
$this->connection = $connection;
105105
$this->processor = $processor;
106-
$this->useCollections = version_compare(\Illuminate\Foundation\Application::VERSION, '5.3', '>=');
106+
$this->useCollections = $this->shouldUseCollections();
107+
}
108+
109+
/**
110+
* Returns true if Laravel or Lumen >= 5.3
111+
*
112+
* @return bool
113+
*/
114+
protected function shouldUseCollections()
115+
{
116+
if (function_exists('app')) {
117+
$version = app()->version();
118+
$version = filter_var(explode(')', $version)[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); // lumen
119+
return version_compare($version, '5.3', '>=');
120+
}
107121
}
108122

109123
/**

0 commit comments

Comments
 (0)