Code Duplication    Length = 32-33 lines in 2 locations

lib/classes/Swift/Transport/FailoverTransport.php 1 location

@@ 37-69 (lines=33) @@
34
     * @return int
35
     * @throws Swift_TransportException
36
     */
37
    public function send(Swift_Mime_Message $message, &$failedRecipients = null)
38
    {
39
        $maxTransports = count($this->_transports);
40
        $sent = 0;
41
        $this->_lastUsedTransport = null;
42
43
        for ($i = 0; $i < $maxTransports
44
                     && $transport = $this->_getNextTransport(); ++$i) {
45
            try {
46
                if (!$transport->isStarted()) {
47
                    $transport->start();
48
                }
49
50
                $sent = $transport->send($message, $failedRecipients);
51
                if ($sent) {
52
                    $this->_lastUsedTransport = $transport;
53
54
                    return $sent;
55
                }
56
57
            } catch (Swift_TransportException $e) {
58
                $this->_killCurrentTransport();
59
            }
60
        }
61
62
        if (count($this->_transports) === 0) {
63
            throw new Swift_TransportException(
64
                'All Transports in FailoverTransport failed, or no Transports available'
65
            );
66
        }
67
68
        return $sent;
69
    }
70
71
    protected function _getNextTransport()
72
    {

lib/classes/Swift/Transport/LoadBalancedTransport.php 1 location

@@ 118-149 (lines=32) @@
115
     *
116
     * @throws Swift_TransportException
117
     */
118
    public function send(Swift_Mime_Message $message, &$failedRecipients = null)
119
    {
120
        $maxTransports = count($this->_transports);
121
        $sent = 0;
122
        $this->_lastUsedTransport = null;
123
124
        for ($i = 0; $i < $maxTransports
125
                     && $transport = $this->_getNextTransport(); ++$i) {
126
            try {
127
                if (!$transport->isStarted()) {
128
                    $transport->start();
129
                }
130
131
                $sent = $transport->send($message, $failedRecipients);
132
                if ($sent) {
133
                    $this->_lastUsedTransport = $transport;
134
                    break;
135
                }
136
137
            } catch (Swift_TransportException $e) {
138
                $this->_killCurrentTransport();
139
            }
140
        }
141
142
        if (count($this->_transports) === 0) {
143
            throw new Swift_TransportException(
144
                'All Transports in LoadBalancedTransport failed, or no Transports available'
145
            );
146
        }
147
148
        return $sent;
149
    }
150
151
    /**
152
     * Register a plugin.