TestHelper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 6
Bugs 3 Features 1
Metric Value
eloc 13
c 6
b 3
f 1
dl 0
loc 23
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A addSentEmails() 0 14 3
1
<?php
2
3
namespace Azine\EmailBundle\Tests;
4
5
use Azine\EmailBundle\Entity\SentEmail;
6
use Azine\EmailBundle\Services\AzineTemplateProvider;
7
use Doctrine\ORM\EntityManager;
8
9
class TestHelper
10
{
11
    const TEST_EMAIL = '[email protected]';
12
    const TEST_TOKEN = 'test_token';
13
14
    /**
15
     * @param EntityManager $manager
16
     * @param int           $count
17
     */
18
    public static function addSentEmails(EntityManager $manager, $count = 1)
19
    {
20
        while ($count > 0) {
21
            $sentEmail = new SentEmail();
22
            $sentEmail->setRecipients(array(self::TEST_EMAIL));
23
            $sentEmail->setSent(new \DateTime('2 weeks ago'));
24
            $sentEmail->setTemplate(AzineTemplateProvider::NEWSLETTER_TEMPLATE);
25
            $sentEmail->setVariables(array());
26
            $sentEmail->setToken(1 == $count ? self::TEST_TOKEN : self::TEST_TOKEN.$count);
27
            $manager->persist($sentEmail);
28
29
            --$count;
30
        }
31
        $manager->flush();
32
    }
33
}
34