Skip to content

Commit 25878f3

Browse files
committed
Add Doc comment for full project
1 parent 24a0650 commit 25878f3

File tree

98 files changed

+1845
-363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1845
-363
lines changed

images/user.png

-2.08 KB
Binary file not shown.

src/Database/Drivers/Driver.php

+30-6
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,56 @@
44

55
class Driver
66
{
7-
7+
/**
8+
* Get connection name
9+
*
10+
* @return string
11+
*/
812
public function getConnectionName()
913
{
1014
return config('database.default', 'mysql');
1115
}
12-
16+
/**
17+
* Check driver is MongoDB
18+
*
19+
* @return bool
20+
*/
1321
public function isMongoDB()
1422
{
1523
return (config('database.default') == 'mongodb') ? true : false;
1624
}
17-
25+
/**
26+
* Check driver is Mysql
27+
*
28+
* @return bool
29+
*/
1830
public function isMysql()
1931
{
2032
return (config('database.default') == 'mysql') ? true : false;
2133
}
22-
34+
/**
35+
* Check driver is Postgresql
36+
*
37+
* @return bool
38+
*/
2339
public function isPostgresql()
2440
{
2541
return (config('database.default') == 'pgsql') ? true : false;
2642
}
27-
43+
/**
44+
* Check driver is Sqlsrv
45+
*
46+
* @return bool
47+
*/
2848
public function isSqlsrv()
2949
{
3050
return (config('database.default') == 'sqlsrv') ? true : false;
3151
}
32-
52+
/**
53+
* Check driver is Sqlite
54+
*
55+
* @return bool
56+
*/
3357
public function isSqlite()
3458
{
3559
return (config('database.default') == 'sqlite') ? true : false;

src/Database/Drivers/MongoDB.php

+137-25
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,35 @@ class MongoDB
1212
{
1313
use MongoConnection;
1414

15-
protected $db;
16-
protected $collection;
17-
protected $databaseName;
18-
protected $collectionName;
19-
15+
/**
16+
* Run MongoDB command
17+
*
18+
* @return \MongoDB\Driver\Cursor
19+
*/
2020
public function command(array $command)
2121
{
2222
return static::getMongoClient()->{$this->admin}->command($command);
2323
}
24-
24+
/**
25+
* Rename collection
26+
*
27+
* @param string $fromNs
28+
* @param string $toNs
29+
*
30+
* @return \MongoDB\Driver\Cursor
31+
*/
2532
public function renameCollection($fromNs, $toNs)
2633
{
2734
return $this->command(array('renameCollection' => $fromNs, 'to' => $toNs));
2835
}
29-
36+
/**
37+
* Rename fields
38+
*
39+
* @param string $collectionName
40+
* @param array $fields
41+
*
42+
* @return void
43+
*/
3044
public function renameFields($collectionName, $fields)
3145
{
3246
$rename = [];
@@ -37,24 +51,42 @@ public function renameFields($collectionName, $fields)
3751
'$rename' => $rename,
3852
);
3953

40-
return $this->selectCollection($collectionName)->updateMany(array(), $update, array('upsert' => true));
54+
$this->selectCollection($collectionName)->updateMany(array(), $update, array('upsert' => true));
4155
}
42-
56+
/**
57+
* Get the MongoDB database object.
58+
*
59+
* @return \MongoDB\Database
60+
*/
4361
public function getDB()
4462
{
4563
return DB::connection()->getMongoDB();
4664
}
47-
65+
/**
66+
* Get the MongoDB collection namespace.
67+
*
68+
* @param string $databaseName
69+
* @param string $collectionName
70+
* @return string
71+
*/
4872
public function getNamespace($databaseName, $collectionName)
4973
{
5074
return $databaseName . '.' . $collectionName;
5175
}
52-
76+
/**
77+
* Get the all collections.
78+
*
79+
* @return \MongoDB\Model\CollectionInfoIterator
80+
*/
5381
public function getCollections()
5482
{
5583
return $this->getDB()->listCollections();
5684
}
57-
85+
/**
86+
* Get the all collections name.
87+
*
88+
* @return array
89+
*/
5890
public function getCollectionNames()
5991
{
6092
$collections = $this->getCollections();
@@ -65,17 +97,35 @@ public function getCollectionNames()
6597

6698
return $collectionNames;
6799
}
68-
100+
/**
101+
* Check MongoDB collection
102+
*
103+
* @param string $collectionName
104+
*
105+
* @return bool
106+
*/
69107
public function hasCollection($collectionName)
70108
{
71109
return (in_array($collectionName, $this->getCollectionNames())) ? true : false;
72110
}
73-
111+
/**
112+
* Create MongoDB colelction
113+
*
114+
* @param string $collectionName
115+
*
116+
* @return array|object Command result document
117+
*/
74118
public function createCollection($collectionName)
75119
{
76120
return $this->getDB()->createCollection($collectionName);
77121
}
78-
122+
/**
123+
* Get MongoDB colelction
124+
*
125+
* @param string $collectionName
126+
*
127+
* @return array
128+
*/
79129
public function getCollection($collectionName)
80130
{
81131
return [
@@ -88,7 +138,13 @@ public function getCollection($collectionName)
88138
'options' => [],
89139
];
90140
}
91-
141+
/**
142+
* Update MongoDB colelction
143+
*
144+
* @param array $collection
145+
*
146+
* @return bool
147+
*/
92148
public function updateCollection($collection)
93149
{
94150

@@ -111,7 +167,14 @@ public function updateCollection($collection)
111167
return true;
112168

113169
}
114-
170+
/**
171+
* Rename MongoDB colelction columns
172+
*
173+
* @param string $collectionName
174+
* @param array $fields
175+
*
176+
* @return void
177+
*/
115178
public function renameColumns($collectionName, $fields)
116179
{
117180
$collection = $this->selectCollection($collectionName);
@@ -139,7 +202,13 @@ public function renameColumns($collectionName, $fields)
139202
}
140203
}
141204
}
142-
205+
/**
206+
* Add MongoDB colelction columns
207+
*
208+
* @param string $collectionName
209+
*
210+
* @return void
211+
*/
143212
public function addColumns($collectionName)
144213
{
145214
$collection = $this->selectCollection($collectionName);
@@ -178,7 +247,13 @@ public function addColumns($collectionName)
178247

179248
}
180249
}
181-
250+
/**
251+
* Remove MongoDB colelction columns
252+
*
253+
* @param string $collectionName
254+
*
255+
* @return void
256+
*/
182257
public function removeColumns($collectionName)
183258
{
184259
$collection = $this->selectCollection($collectionName);
@@ -198,7 +273,14 @@ public function removeColumns($collectionName)
198273
$collection->updateMany(array(), $update, array('upsert' => true));
199274
}
200275
}
201-
276+
/**
277+
* Set MongoDB colelction fields
278+
*
279+
* @param string $collectionName
280+
* @param array $fields
281+
*
282+
* @return void
283+
*/
202284
public function setFields($collectionName, $fields)
203285
{
204286
/*
@@ -216,17 +298,35 @@ public function setFields($collectionName, $fields)
216298
$this->removeColumns($collectionName);
217299
return true;
218300
}
219-
301+
/**
302+
* Drop MongoDB colelction
303+
*
304+
* @param string $collectionName
305+
*
306+
* @return void
307+
*/
220308
public function dropCollection($collectionName)
221309
{
222310
$this->getDB()->dropCollection($collectionName);
223311
}
224-
312+
/**
313+
* Select MongoDB colelction
314+
*
315+
* @param string $collectionName
316+
*
317+
* @return \MongoDB\Collection
318+
*/
225319
public function selectCollection($collectionName)
226320
{
227321
return $this->getDB()->selectCollection($collectionName);
228322
}
229-
323+
/**
324+
* Get MongoDB colelction columns
325+
*
326+
* @param string $collectionName
327+
*
328+
* @return array
329+
*/
230330
public function getCollectionColumns($collectionName)
231331
{
232332
$cursor = $this->selectCollection($collectionName)->find();
@@ -241,7 +341,13 @@ public function getCollectionColumns($collectionName)
241341

242342
return array_values(array_unique($columnNames));
243343
}
244-
344+
/**
345+
* Get MongoDB columns
346+
*
347+
* @param string $collectionName
348+
*
349+
* @return array
350+
*/
245351
public function getColumns($collectionName)
246352
{
247353
$columns = [];
@@ -279,7 +385,13 @@ public function getColumns($collectionName)
279385

280386
return $columns;
281387
}
282-
388+
/**
389+
* Get colelction ColumnsName
390+
*
391+
* @param string $collectionName
392+
*
393+
* @return \Illuminate\Support\Collection
394+
*/
283395
public function getColumnsName($collectionName)
284396
{
285397
return DBM_Collection::where('name', $collectionName)->first()->fields->pluck('name')->toArray();

0 commit comments

Comments
 (0)