diff --git a/README.md b/README.md index d608f32..700b80a 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,8 @@ use bkrukowski\TransparentEmail\Emails\EmailInterface; use bkrukowski\TransparentEmail\Emails\InvalidEmailException; try { - $cleaner = TransparentEmailFactory::createDefault(); + $factory = new TransparentEmailFactory(); + $cleaner = $factory->createDefault(); $inputEmail = new Email('John.Doe+alias@gmail.com'); /** @var EmailInterface $transformedEmail */ $transformedEmail = $cleaner->getPrimaryEmail($inputEmail); diff --git a/src/TransparentEmailFactory.php b/src/TransparentEmailFactory.php index 8765924..fff5cd7 100644 --- a/src/TransparentEmailFactory.php +++ b/src/TransparentEmailFactory.php @@ -13,23 +13,23 @@ use bkrukowski\TransparentEmail\Services\YahooCom; class TransparentEmailFactory { - public static function createDefault() : TransparentEmailInterface + public function createDefault() : TransparentEmailInterface { - return new TransparentEmail(self::createServiceCollector()); + return new TransparentEmail($this->createServiceCollector()); } - private static function createServiceCollector() : ServiceCollectorInterface + private function createServiceCollector() : ServiceCollectorInterface { $collector = new ServiceCollector(); - foreach (self::getAllServicesClasses() as $servicesClass) { + foreach ($this->getAllServicesClasses() as $servicesClass) { $collector->addService(new $servicesClass()); } return $collector; } - private static function getAllServicesClasses() : array + private function getAllServicesClasses() : array { return [ GmailCom::class, diff --git a/tests/TransparentEmailFactoryTest.php b/tests/TransparentEmailFactoryTest.php index b54366d..d84b919 100644 --- a/tests/TransparentEmailFactoryTest.php +++ b/tests/TransparentEmailFactoryTest.php @@ -18,7 +18,7 @@ class TransparentEmailFactoryTest extends \PHPUnit_Framework_TestCase */ public function testExpectedEmail(EmailInterface $inputEmail, string $expectedEmail) { - $outputEmail = TransparentEmailFactory::createDefault()->getPrimaryEmail($inputEmail); + $outputEmail = (new TransparentEmailFactory())->createDefault()->getPrimaryEmail($inputEmail); $this->assertSame($expectedEmail, (string) $outputEmail); } diff --git a/tests/TransparentEmailTest.php b/tests/TransparentEmailTest.php index bd1c56f..ae69db6 100644 --- a/tests/TransparentEmailTest.php +++ b/tests/TransparentEmailTest.php @@ -42,12 +42,12 @@ class TransparentEmailTest extends \PHPUnit_Framework_TestCase 'john.doe+alias@gmail.com', 'john.doe+alias@gmail.com' ], - [TransparentEmailFactory::createDefault(), 'john.doe+alias@gmail.com', 'johndoe@gmail.com'], + [(new TransparentEmailFactory())->createDefault(), 'john.doe+alias@gmail.com', 'johndoe@gmail.com'], [new TransparentEmail($emptyServiceCollector), 'John.Doe@example.com', 'john.doe@example.com'], [new TransparentEmail($emptyServiceCollector), 'John.Doe@example.com', 'John.Doe@example.com', true], - [TransparentEmailFactory::createDefault(), 'John.Doe@gmail.com', 'johndoe@gmail.com', true], - [TransparentEmailFactory::createDefault(), 'Jane.Doe+receipts@hotmail.com', 'jane.doe@hotmail.com'], - [TransparentEmailFactory::createDefault(), 'Jane.Doe-receipts@yahoo.com', 'jane.doe@yahoo.com'], + [(new TransparentEmailFactory())->createDefault(), 'John.Doe@gmail.com', 'johndoe@gmail.com', true], + [(new TransparentEmailFactory())->createDefault(), 'Jane.Doe+receipts@hotmail.com', 'jane.doe@hotmail.com'], + [(new TransparentEmailFactory())->createDefault(), 'Jane.Doe-receipts@yahoo.com', 'jane.doe@yahoo.com'], ]; } @@ -59,7 +59,7 @@ class TransparentEmailTest extends \PHPUnit_Framework_TestCase */ public function testDefault(EmailInterface $inputEmail, string $expectedEmail) { - $this->assertEquals($expectedEmail, (TransparentEmailFactory::createDefault())->getPrimaryEmail($inputEmail)); + $this->assertEquals($expectedEmail, ((new TransparentEmailFactory())->createDefault())->getPrimaryEmail($inputEmail)); } public function providerDefault() : array