Skip to content

Commit c696894

Browse files
committed
Code commented
1 parent f3e8628 commit c696894

File tree

4 files changed

+181
-72
lines changed

4 files changed

+181
-72
lines changed

src/IMAP/Client.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
use Webklex\IMAP\Exceptions\ConnectionFailedException;
1818
use Webklex\IMAP\Exceptions\GetMessagesFailedException;
1919

20-
class Client
21-
{
20+
class Client {
2221
/**
2322
* @var bool|resource
2423
*/
@@ -242,6 +241,12 @@ public function openFolder(Folder $folder)
242241
}
243242
}
244243

244+
/**
245+
* Create a new Folder
246+
* @param $name
247+
*
248+
* @return bool
249+
*/
245250
public function createFolder($name){
246251
return imap_createmailbox($this->connection, imap_utf7_encode($name));
247252
}
@@ -310,4 +315,4 @@ protected function getAddress()
310315

311316
return $address;
312317
}
313-
}
318+
}

src/IMAP/ClientManager.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,37 @@
1212

1313
namespace Webklex\IMAP;
1414

15-
class ClientManager
16-
{
15+
class ClientManager {
16+
1717
/**
1818
* The application instance.
1919
*
2020
* @var \Illuminate\Foundation\Application
2121
*/
2222
protected $app;
2323

24+
/**
25+
* @var array $accounts
26+
*/
2427
protected $accounts = [];
2528

2629
/**
2730
* Create a new client manager instance.
2831
*
2932
* @param \Illuminate\Foundation\Application $app
3033
*/
31-
public function __construct($app)
32-
{
34+
public function __construct($app) {
3335
$this->app = $app;
3436
}
3537

3638
/**
3739
* Resolve a account instance.
3840
*
3941
* @param string $name
42+
*
4043
* @return \Webklex\IMAP\Client
4144
*/
42-
public function account($name = null)
43-
{
45+
public function account($name = null) {
4446
$name = $name ?: $this->getDefaultAccount();
4547

4648
// If the connection has not been resolved yet we will resolve it now as all
@@ -57,10 +59,10 @@ public function account($name = null)
5759
* Resolve a account.
5860
*
5961
* @param string $name
62+
*
6063
* @return \Webklex\IMAP\Client
6164
*/
62-
protected function resolve($name)
63-
{
65+
protected function resolve($name) {
6466
$config = $this->getConfig($name);
6567

6668
return new Client($config);
@@ -70,10 +72,10 @@ protected function resolve($name)
7072
* Get the account configuration.
7173
*
7274
* @param string $name
75+
*
7376
* @return array
7477
*/
75-
protected function getConfig($name)
76-
{
78+
protected function getConfig($name) {
7779
if ($name === null || $name === 'null') {
7880
return ['driver' => 'null'];
7981
}
@@ -86,19 +88,18 @@ protected function getConfig($name)
8688
*
8789
* @return string
8890
*/
89-
public function getDefaultAccount()
90-
{
91+
public function getDefaultAccount() {
9192
return $this->app['config']['imap.default'];
9293
}
9394

9495
/**
9596
* Set the name of the default account.
9697
*
9798
* @param string $name
99+
*
98100
* @return void
99101
*/
100-
public function setDefaultAccount($name)
101-
{
102+
public function setDefaultAccount($name) {
102103
$this->app['config']['imap.default'] = $name;
103104
}
104105

@@ -107,10 +108,10 @@ public function setDefaultAccount($name)
107108
*
108109
* @param string $method
109110
* @param array $parameters
111+
*
110112
* @return mixed
111113
*/
112-
public function __call($method, $parameters)
113-
{
114+
public function __call($method, $parameters) {
114115
$callable = [$this->account(), $method];
115116

116117
return call_user_func_array($callable, $parameters);

src/IMAP/Folder.php

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313
namespace Webklex\IMAP;
1414

15-
class Folder
16-
{
15+
class Folder {
1716
/**
1817
* Client instance
1918
*
@@ -99,16 +98,16 @@ class Folder
9998
* Folder constructor.
10099
*
101100
* @param \Webklex\IMAP\Client $client
101+
*
102102
* @param $folder
103103
*/
104-
public function __construct(Client $client, $folder)
105-
{
104+
public function __construct(Client $client, $folder) {
106105
$this->client = $client;
107106

108107
$this->delimiter = $folder->delimiter;
109-
$this->path = $folder->name;
110-
$this->fullName = $this->decodeName($folder->name);
111-
$this->name = $this->getSimpleName($this->delimiter, $this->fullName);
108+
$this->path = $folder->name;
109+
$this->fullName = $this->decodeName($folder->name);
110+
$this->name = $this->getSimpleName($this->delimiter, $this->fullName);
112111

113112
$this->parseAttributes($folder->attributes);
114113
}
@@ -118,8 +117,7 @@ public function __construct(Client $client, $folder)
118117
*
119118
* @return bool
120119
*/
121-
public function hasChildren()
122-
{
120+
public function hasChildren() {
123121
return $this->has_children;
124122
}
125123

@@ -128,8 +126,7 @@ public function hasChildren()
128126
*
129127
* @param array $children
130128
*/
131-
public function setChildren($children = [])
132-
{
129+
public function setChildren($children = []) {
133130
$this->children = $children;
134131
}
135132

@@ -140,8 +137,7 @@ public function setChildren($children = [])
140137
*
141138
* @return array
142139
*/
143-
public function getMessages($criteria = 'ALL')
144-
{
140+
public function getMessages($criteria = 'ALL') {
145141
return $this->client->getMessages($this, $criteria);
146142
}
147143

@@ -153,8 +149,7 @@ public function getMessages($criteria = 'ALL')
153149
*
154150
* @return mixed|string
155151
*/
156-
protected function decodeName($name)
157-
{
152+
protected function decodeName($name) {
158153
preg_match('#\{(.*)\}(.*)#', $name, $preg);
159154
return mb_convert_encoding($preg[2], "UTF-8", "UTF7-IMAP");
160155
}
@@ -167,8 +162,7 @@ protected function decodeName($name)
167162
*
168163
* @return mixed
169164
*/
170-
protected function getSimpleName($delimiter, $fullName)
171-
{
165+
protected function getSimpleName($delimiter, $fullName) {
172166
$arr = explode($delimiter, $fullName);
173167

174168
return end($arr);
@@ -179,8 +173,7 @@ protected function getSimpleName($delimiter, $fullName)
179173
*
180174
* @param $attributes
181175
*/
182-
protected function parseAttributes($attributes)
183-
{
176+
protected function parseAttributes($attributes) {
184177
$this->no_inferiors = ($attributes & LATT_NOINFERIORS) ? true : false;
185178
$this->no_select = ($attributes & LATT_NOSELECT) ? true : false;
186179
$this->marked = ($attributes & LATT_MARKED) ? true : false;

0 commit comments

Comments
 (0)