Code Duplication    Length = 14-15 lines in 2 locations

src/SilverStripe/BehatExtension/Context/EmailContext.php 2 locations

@@ 140-154 (lines=15) @@
137
    /**
138
     * @When /^I click on the "([^"]*)" link in the email (to|from) "([^"]*)"$/
139
     */
140
    public function iGoToInTheEmailTo($linkSelector, $direction, $email)
141
    {
142
        $to = ($direction == 'to') ? $email : null;
143
        $from = ($direction == 'from') ? $email : null;
144
        $match = $this->mailer->findEmail($to, $from);
145
        assertNotNull($match);
146
147
        $crawler = new Crawler($match->Content);
148
        $linkEl = $crawler->selectLink($linkSelector);
149
        assertNotNull($linkEl);
150
        $link = $linkEl->attr('href');
151
        assertNotNull($link);
152
        
153
        return new Step\When(sprintf('I go to "%s"', $link));
154
    }
155
156
    /**
157
     * @When /^I click on the "([^"]*)" link in the email (to|from) "([^"]*)" titled "([^"]*)"$/
@@ 159-172 (lines=14) @@
156
    /**
157
     * @When /^I click on the "([^"]*)" link in the email (to|from) "([^"]*)" titled "([^"]*)"$/
158
     */
159
    public function iGoToInTheEmailToTitled($linkSelector, $direction, $email, $title)
160
    {
161
        $to = ($direction == 'to') ? $email : null;
162
        $from = ($direction == 'from') ? $email : null;
163
        $match = $this->mailer->findEmail($to, $from, $title);
164
        assertNotNull($match);
165
166
        $crawler = new Crawler($match->Content);
167
        $linkEl = $crawler->selectLink($linkSelector);
168
        assertNotNull($linkEl);
169
        $link = $linkEl->attr('href');
170
        assertNotNull($link);
171
        return new Step\When(sprintf('I go to "%s"', $link));
172
    }
173
    
174
    /**
175
     * Assumes an email has been identified by a previous step,