Code Duplication    Length = 17-18 lines in 4 locations

src/Davispeixoto/ForceDotComToolkitForPhp/SforceBaseClient.php 2 locations

@@ 584-601 (lines=18) @@
581
        return $this->sforce->upsert($arg)->result;
582
    }
583
584
    public function sendSingleEmail($request)
585
    {
586
        if (is_array($request)) {
587
            $messages = array();
588
            foreach ($request as $r) {
589
                $email = new SoapVar($r, SOAP_ENC_OBJECT, 'SingleEmailMessage', $this->namespace);
590
                array_push($messages, $email);
591
            }
592
            $arg = new stdClass();
593
            $arg->messages = $messages;
594
595
            return $this->_sendEmail($arg);
596
        } else {
597
            $backtrace = debug_backtrace();
598
            error_log('Please pass in array to this function:  ' . $backtrace[0]['function']);
599
            return false;
600
        }
601
    }
602
603
    public function sendMassEmail($request)
604
    {
@@ 603-620 (lines=18) @@
600
        }
601
    }
602
603
    public function sendMassEmail($request)
604
    {
605
        if (is_array($request)) {
606
            $messages = array();
607
            foreach ($request as $r) {
608
                $email = new SoapVar($r, SOAP_ENC_OBJECT, 'MassEmailMessage', $this->namespace);
609
                array_push($messages, $email);
610
            }
611
            $arg = new stdClass();
612
            $arg->messages = $messages;
613
614
            return $this->_sendEmail($arg);
615
        } else {
616
            $backtrace = debug_backtrace();
617
            error_log('Please pass in array to this function:  ' . $backtrace[0]['function']);
618
            return false;
619
        }
620
    }
621
622
    protected function _sendEmail($arg)
623
    {

src/Davispeixoto/ForceDotComToolkitForPhp/SforcePartnerClient.php 2 locations

@@ 91-107 (lines=17) @@
88
     *
89
     * @param array $request
90
     */
91
    public function sendSingleEmail($request)
92
    {
93
        if (is_array($request)) {
94
            $messages = array();
95
            foreach ($request as $r) {
96
                $email = new \SoapVar($r, SOAP_ENC_OBJECT, 'SingleEmailMessage', $this->namespace);
97
                array_push($messages, $email);
98
            }
99
            $arg->messages = $messages;
100
101
            return parent::_sendEmail($arg);
102
        } else {
103
            $backtrace = debug_backtrace();
104
            error_log('Please pass in array to this function:  ' . $backtrace[0]['function']);
105
            return false;
106
        }
107
    }
108
109
    /**
110
     *
@@ 113-130 (lines=18) @@
110
     *
111
     * @param array $request
112
     */
113
    public function sendMassEmail($request)
114
    {
115
        $arg = new stdClass();
116
        if (is_array($request)) {
117
            $messages = array();
118
            foreach ($request as $r) {
119
                $email = new \SoapVar($r, SOAP_ENC_OBJECT, 'MassEmailMessage', $this->namespace);
120
                array_push($messages, $email);
121
            }
122
            $arg->messages = $messages;
123
124
            return parent::_sendEmail($arg);
125
        } else {
126
            $backtrace = debug_backtrace();
127
            error_log('Please pass in array to this function:  ' . $backtrace[0]['function']);
128
            return false;
129
        }
130
    }
131
132
    /**
133
     * Updates one or more new individual objects to your organization's data.