-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Send only the domain to bing for grabbing an image
- Loading branch information
1 parent
f5751d7
commit 870a58f
Showing
7 changed files
with
171 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
namespace In2code\Lux\Domain\Service\Provider; | ||
|
||
use TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException; | ||
|
||
/** | ||
* Class CustomerMail | ||
* this class can decide if an email belongs to a b2c or b2b contact | ||
*/ | ||
class CustomerMail | ||
{ | ||
protected array $b2cEmailDomains = [ | ||
'1und1.de', | ||
'aok.de', | ||
'aon.at', | ||
'arcor.de', | ||
'barmer.de', | ||
'bluemail.ch', | ||
'bluewin.ch', | ||
'chello.at', | ||
'dak.de', | ||
'email.de', | ||
'ewe.net', | ||
'freenet.de', | ||
'gmail.com', | ||
'gmx.at', | ||
'gmx.ch', | ||
'gmx.de', | ||
'gmx.net', | ||
'googlemail.com', | ||
'hotmail.com', | ||
'hotmail.de', | ||
'htp-tel.de', | ||
'icloud.com', | ||
'ikk-classic.de', | ||
'kabelbw.de', | ||
'live.com', | ||
'mac.com', | ||
'mail.de', | ||
'me.com', | ||
'mozmail.com', | ||
'o2online.de', | ||
'online.de', | ||
'osnanet.de', | ||
'ostfalia.de', | ||
'outlook.com', | ||
'outlook.de', | ||
'posteo.de', | ||
't-online.de', | ||
'telekom.de', | ||
'tk.de', | ||
'versanet.de', | ||
'vodafone.de', | ||
'vodafonemail.de', | ||
'web.de', | ||
'yahoo.com', | ||
'yahoo.de', | ||
]; | ||
|
||
public function __construct(protected readonly AllowedMail $allowedMail) | ||
{ | ||
} | ||
|
||
public function isB2cEmail(string $email): bool | ||
{ | ||
$domain = strtolower(substr(strrchr($email, '@'), 1)); | ||
return in_array($domain, $this->b2cEmailDomains) || $this->allowedMail->isEmailAllowed($email) === false; | ||
} | ||
|
||
public function isB2bEmail(string $email): bool | ||
{ | ||
return $this->isB2cEmail($email) === false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace In2code\Lux\Tests\Unit\Utility; | ||
|
||
use In2code\Lux\Utility\EmailUtility; | ||
use TYPO3\TestingFramework\Core\Unit\UnitTestCase; | ||
|
||
/** | ||
* @coversDefaultClass EmailUtility | ||
*/ | ||
class EmailUtilityTest extends UnitTestCase | ||
{ | ||
public static function extendEmailReceiverArrayDataProvider(): array | ||
{ | ||
return [ | ||
[ | ||
[ | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
], | ||
null, | ||
[ | ||
'[email protected]' => 'receiver', | ||
'[email protected]' => 'receiver', | ||
'[email protected]' => 'receiver', | ||
], | ||
], | ||
[ | ||
[ | ||
'[email protected]', | ||
'[email protected]', | ||
], | ||
'name', | ||
[ | ||
'[email protected]' => 'name', | ||
'[email protected]' => 'name', | ||
], | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @param array $emails | ||
* @param string|null $name | ||
* @param array $expectedResult | ||
* @return void | ||
* @dataProvider extendEmailReceiverArrayDataProvider | ||
* @covers ::extendEmailReceiverArray | ||
*/ | ||
public function testExtendEmailReceiverArray(array $emails, ?string $name, array $expectedResult): void | ||
{ | ||
if ($name !== null) { | ||
$result = EmailUtility::extendEmailReceiverArray($emails, $name); | ||
} else { | ||
$result = EmailUtility::extendEmailReceiverArray($emails); | ||
} | ||
$this->assertSame($expectedResult, $result); | ||
} | ||
|
||
/** | ||
* @return void | ||
* @covers ::getDomainFromEmail | ||
*/ | ||
public function testGetDomainFromEmail(): void | ||
{ | ||
$this->assertSame('in2code.de', EmailUtility::getDomainFromEmail('[email protected]')); | ||
$this->assertSame('fuz.bayern', EmailUtility::getDomainFromEmail('[email protected]')); | ||
$this->assertSame('', EmailUtility::getDomainFromEmail('')); | ||
$this->assertSame('', EmailUtility::getDomainFromEmail('foobar')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters