Skip to content

Commit 026da03

Browse files
committed
FolderCollection added
1 parent 44d0f00 commit 026da03

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ $aMessage = $oFolder->getMessages('ALL', null, false);
277277
| connect | int $attempts | | Connect to server. |
278278
| disconnect | | | Disconnect from server. |
279279
| getFolder | string $folder_name, int $attributes = 32, int or null $delimiter | Folder | Get a Folder instance by name |
280-
| getFolders | bool $hierarchical, string or null $parent_folder | array | Get folders list. If hierarchical order is set to true, it will make a tree of folders, otherwise it will return flat array. |
280+
| getFolders | bool $hierarchical, string or null $parent_folder | FolderCollection | Get folders list. If hierarchical order is set to true, it will make a tree of folders, otherwise it will return flat array. |
281281
| openFolder | Folder $folder, $attempts | | Open a given folder. |
282282
| createFolder | string $name | | Create a new folder. |
283283
| getMessages | Folder $folder, string $criteria, bool $parse_body | MessageCollection | Get messages from folder. |
@@ -369,6 +369,13 @@ Extends [Illuminate\Support\Collection::class](https://laravel.com/api/5.4/Illum
369369
| -------- | --------------------------------------------------- | :------------------: | -------------------------------- |
370370
| paginate | int $perPage = 15, $page = null, $pageName = 'page' | LengthAwarePaginator | Paginate the current collection. |
371371

372+
### [FolderCollection::class](src/IMAP/Support/FolderCollection.php)
373+
Extends [Illuminate\Support\Collection::class](https://laravel.com/api/5.4/Illuminate/Support/Collection.html)
374+
375+
| Method | Arguments | Return | Description |
376+
| -------- | --------------------------------------------------- | :------------------: | -------------------------------- |
377+
| paginate | int $perPage = 15, $page = null, $pageName = 'page' | LengthAwarePaginator | Paginate the current collection. |
378+
372379
### Known issues
373380
| Error | Solution |
374381
| ------------------------------------------------------------------------- | ---------------------------------------------------------- |

src/IMAP/Client.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Webklex\IMAP\Exceptions\ConnectionFailedException;
1616
use Webklex\IMAP\Exceptions\GetMessagesFailedException;
1717
use Webklex\IMAP\Exceptions\MessageSearchValidationException;
18+
use Webklex\IMAP\Support\FolderCollection;
1819
use Webklex\IMAP\Support\MessageCollection;
1920

2021
/**
@@ -252,11 +253,11 @@ public function getFolder($folder_name, $attributes = 32, $delimiter = null){
252253
* @param bool $hierarchical
253254
* @param null $parent_folder
254255
*
255-
* @return array
256+
* @return FolderCollection
256257
*/
257258
public function getFolders($hierarchical = true, $parent_folder = null) {
258259
$this->checkConnection();
259-
$folders = [];
260+
$folders = FolderCollection::make([]);
260261

261262
$pattern = $parent_folder.($hierarchical ? '%' : '*');
262263

@@ -270,7 +271,8 @@ public function getFolders($hierarchical = true, $parent_folder = null) {
270271
$children = $this->getFolders(true, $pattern);
271272
$folder->setChildren($children);
272273
}
273-
$folders[] = $folder;
274+
275+
$folders->push($folder);
274276
}
275277

276278
return $folders;

src/IMAP/Folder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use Webklex\IMAP\Exceptions\GetMessagesFailedException;
1616
use Webklex\IMAP\Exceptions\MessageSearchValidationException;
17+
use Webklex\IMAP\Support\FolderCollection;
1718
use Webklex\IMAP\Support\MessageCollection;
1819

1920
/**
@@ -54,7 +55,7 @@ class Folder {
5455
/**
5556
* Children folders
5657
*
57-
* @var array
58+
* @var FolderCollection|array
5859
*/
5960
public $children = [];
6061

@@ -134,7 +135,7 @@ public function hasChildren() {
134135
/**
135136
* Set children.
136137
*
137-
* @param array $children
138+
* @param FolderCollection|array $children
138139
*
139140
* @return self
140141
*/
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/*
3+
* File: FolderCollection.php
4+
* Category: Collection
5+
* Author: M. Goldenbaum
6+
* Created: 18.03.18 02:21
7+
* Updated: -
8+
*
9+
* Description:
10+
* -
11+
*/
12+
13+
namespace Webklex\IMAP\Support;
14+
15+
/**
16+
* Class FolderCollection
17+
*
18+
* @package Webklex\IMAP\Support
19+
*/
20+
class FolderCollection extends PaginatedCollection {
21+
22+
}

0 commit comments

Comments
 (0)