Code Duplication    Length = 32-33 lines in 2 locations

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

@@ 79-111 (lines=33) @@
76
     * @return int
77
     * @throws Swift_TransportException
78
     */
79
    public function send(Swift_Mime_Message $message, &$failedRecipients = null)
80
    {
81
        $maxTransports = count($this->_transports);
82
        $sent = 0;
83
        $this->_lastUsedTransport = null;
84
85
        for ($i = 0; $i < $maxTransports
86
                     && $transport = $this->_getNextTransport(); ++$i) {
87
            try {
88
                if (!$transport->isStarted()) {
89
                    $transport->start();
90
                }
91
92
                $sent = $transport->send($message, $failedRecipients);
93
                if ($sent) {
94
                    $this->_lastUsedTransport = $transport;
95
96
                    return $sent;
97
                }
98
99
            } catch (Swift_TransportException $e) {
100
                $this->_killCurrentTransport();
101
            }
102
        }
103
104
        if (count($this->_transports) === 0) {
105
            throw new Swift_TransportException(
106
                'All Transports in FailoverTransport failed, or no Transports available'
107
            );
108
        }
109
110
        return $sent;
111
    }
112
113
    protected function _getNextTransport()
114
    {

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

@@ 148-179 (lines=32) @@
145
     *
146
     * @throws Swift_TransportException
147
     */
148
    public function send(Swift_Mime_Message $message, &$failedRecipients = null)
149
    {
150
        $maxTransports = count($this->_transports);
151
        $sent = 0;
152
        $this->_lastUsedTransport = null;
153
154
        for ($i = 0; $i < $maxTransports
155
                     && $transport = $this->_getNextTransport(); ++$i) {
156
            try {
157
                if (!$transport->isStarted()) {
158
                    $transport->start();
159
                }
160
161
                $sent = $transport->send($message, $failedRecipients);
162
                if ($sent) {
163
                    $this->_lastUsedTransport = $transport;
164
                    break;
165
                }
166
167
            } catch (Swift_TransportException $e) {
168
                $this->_killCurrentTransport();
169
            }
170
        }
171
172
        if (count($this->_transports) === 0) {
173
            throw new Swift_TransportException(
174
                'All Transports in LoadBalancedTransport failed, or no Transports available'
175
            );
176
        }
177
178
        return $sent;
179
    }
180
181
    /**
182
     * Register a plugin.