Skip to content

Commit 6ad5cec

Browse files
refactor: rename MailAccount's "root" to "subscriptions"
refs conjoon/conjoon#23
1 parent d54c003 commit 6ad5cec

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

src/Mail/Client/Data/MailAccount.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* conjoon
55
* php-lib-conjoon
6-
* Copyright (C) 2019-2022 Thorsten Suckow-Homberg https://github.com/conjoon/php-lib-conjoon
6+
* Copyright (C) 2019-2023 Thorsten Suckow-Homberg https://github.com/conjoon/php-lib-conjoon
77
*
88
* Permission is hereby granted, free of charge, to any person
99
* obtaining a copy of this software and associated documentation
@@ -56,14 +56,14 @@
5656
* "outbox_user" => "outboxuser",
5757
* "outbox_password" => "outboxpassword',
5858
* 'outbox_secure' => "tls",
59-
* 'root' => "INBOX"
59+
* 'subscriptions' => ["INBOX"]
6060
* ]);
6161
*
6262
* $account->getOutboxSecure(); // true
6363
* $account->getInboxPort(); // 993
6464
* $account->getReplyTo(); // ['name' => 'John Smith', 'address' => '[email protected]'],
6565
*
66-
* The property "root" allows for specifying a root mailbox and defaults to "INBOX".
66+
* The property "subscriptions" allows for specifying mailbox the account is subscribed to.
6767
*
6868
* @package Conjoon\Mail\Client\Data
6969
*
@@ -82,7 +82,7 @@
8282
* @method string getOutboxAddress()
8383
* @method int getOutboxPort()
8484
* @method string getOutboxSecure()
85-
* @method array getRoot()
85+
* @method array getSubscriptions()
8686
*
8787
* @noinspection SpellCheckingInspection
8888
*/
@@ -166,7 +166,7 @@ class MailAccount implements Jsonable, Arrayable
166166
/**
167167
* @var array
168168
*/
169-
protected array $root = ["INBOX"];
169+
protected array $subscriptions = ["INBOX"];
170170

171171
/**
172172
* MailAccount constructor.
@@ -240,7 +240,7 @@ public function toArray(): array
240240
"outbox_user" => $this->getOutboxUser(),
241241
"outbox_password" => $this->getOutboxPassword(),
242242
"outbox_secure" => $this->getOutboxSecure(),
243-
"root" => $this->getRoot()
243+
"subscriptions" => $this->getSubscriptions()
244244
];
245245
}
246246

src/Mail/Client/Service/DefaultMailFolderService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* conjoon
55
* php-lib-conjoon
6-
* Copyright (C) 2019-2022 Thorsten Suckow-Homberg https://github.com/conjoon/php-lib-conjoon
6+
* Copyright (C) 2019-2023 Thorsten Suckow-Homberg https://github.com/conjoon/php-lib-conjoon
77
*
88
* Permission is hereby granted, free of charge, to any person
99
* obtaining a copy of this software and associated documentation
@@ -92,10 +92,10 @@ public function getMailClient(): MailClient
9292
/**
9393
* @inheritdoc
9494
*/
95-
public function getMailFolderChildList(MailAccount $mailAccount): MailFolderChildList
95+
public function getMailFolderChildList(MailAccount $mailAccount, array $subscriptions = []): MailFolderChildList
9696
{
9797
$mailFolderList = $this->getMailClient()->getMailFolderList($mailAccount);
9898

99-
return $this->getMailFolderTreeBuilder()->listToTree($mailFolderList, $mailAccount->getRoot());
99+
return $this->getMailFolderTreeBuilder()->listToTree($mailFolderList, $subscriptions);
100100
}
101101
}

src/Mail/Client/Service/MailFolderService.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* conjoon
55
* php-lib-conjoon
6-
* Copyright (C) 2019-2022 Thorsten Suckow-Homberg https://github.com/conjoon/php-lib-conjoon
6+
* Copyright (C) 2019-2023 Thorsten Suckow-Homberg https://github.com/conjoon/php-lib-conjoon
77
*
88
* Permission is hereby granted, free of charge, to any person
99
* obtaining a copy of this software and associated documentation
@@ -40,6 +40,7 @@ interface MailFolderService
4040
* MailAccount.
4141
*
4242
* @param MailAccount $mailAccount
43+
* @param array $subscriptions
4344
*
4445
* @return MailFolderChildList An MailFolderChildList of the Mailbox-structure
4546
* found on the server.
@@ -55,7 +56,7 @@ interface MailFolderService
5556
*
5657
* @see \Horde_Imap_Client_Socket
5758
*/
58-
public function getMailFolderChildList(MailAccount $mailAccount): MailFolderChildList;
59+
public function getMailFolderChildList(MailAccount $mailAccount, array $subscriptions = []): MailFolderChildList;
5960

6061

6162
/**

tests/Mail/Client/Data/MailAccountTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* conjoon
55
* php-lib-conjoon
6-
* Copyright (C) 2019-2022 Thorsten Suckow-Homberg https://github.com/conjoon/php-lib-conjoon
6+
* Copyright (C) 2019-2023 Thorsten Suckow-Homberg https://github.com/conjoon/php-lib-conjoon
77
*
88
* Permission is hereby granted, free of charge, to any person
99
* obtaining a copy of this software and associated documentation
@@ -59,7 +59,7 @@ class MailAccountTest extends TestCase
5959
"outbox_user" => "user",
6060
"outbox_password" => "password outbox",
6161
"outbox_secure" => "ssl",
62-
"root" => ["[Gmail]"]
62+
"subscriptions" => ["[Gmail]"]
6363
];
6464

6565

@@ -81,14 +81,14 @@ public function testGetter()
8181
{
8282
$config = $this->accountConfig;
8383

84-
$oldRoot = $config["root"];
84+
$oldRoot = $config["subscriptions"];
8585
$this->assertSame(["[Gmail]"], $oldRoot);
86-
unset($config["root"]);
86+
unset($config["subscriptions"]);
8787

8888
$account = new MailAccount($config);
89-
$this->assertSame(["INBOX"], $account->getRoot());
89+
$this->assertSame(["INBOX"], $account->getSubscriptions());
9090

91-
$config["root"] = $oldRoot;
91+
$config["subscriptions"] = $oldRoot;
9292
$account = new MailAccount($config);
9393

9494
foreach ($config as $property => $value) {

tests/Mail/Client/Service/DefaultMailFolderServiceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* conjoon
55
* php-lib-conjoon
6-
* Copyright (C) 2019-2022 Thorsten Suckow-Homberg https://github.com/conjoon/php-lib-conjoon
6+
* Copyright (C) 2019-2023 Thorsten Suckow-Homberg https://github.com/conjoon/php-lib-conjoon
77
*
88
* Permission is hereby granted, free of charge, to any person
99
* obtaining a copy of this software and associated documentation
@@ -90,7 +90,7 @@ public function testGetMailFolderChildList()
9090
->with($mailFolderList, ["INBOX"])
9191
->andReturn($resultList);
9292

93-
$this->assertSame($resultList, $service->getMailFolderChildList($mailAccount));
93+
$this->assertSame($resultList, $service->getMailFolderChildList($mailAccount, ["INBOX"]));
9494
}
9595

9696

0 commit comments

Comments
 (0)