Salesforce::dump()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace Davispeixoto\LaravelSalesforce;
2
3
use Davispeixoto\ForceDotComToolkitForPhp\SforceEnterpriseClient as Client;
4
use Exception;
5
6
/**
7
 * Class Salesforce
8
 *
9
 * Provides an easy binding to Salesforce
10
 * on Laravel 4 applications through SOAP
11
 * Data Integration.
12
 *
13
 * @package Davispeixoto\LaravelSalesforce
14
 */
15
class Salesforce
16
{
17
    /**
18
     * @var Client $sfh The Salesforce Handler
19
     */
20
    public $sfh;
21
22
    /**
23
     * Salesforce constructor.
24
     *
25
     * @param Client $sfh
26
     * @throws SalesforceException
27
     */
28
    public function __construct(Client $sfh)
29
    {
30
        $this->sfh = $sfh;
31
    }
32
33
    /**
34
     * @param $method
35
     * @param $args
36
     * @return mixed
37
     */
38
    public function __call($method, $args)
39
    {
40
        return call_user_func_array(array($this->sfh, $method), $args);
41
    }
42
43
    /**
44
     * Authenticates into Salesforce according to
45
     * the provided credentials and WSDL file
46
     *
47
     * @param $configExternal
48
     * @throws SalesforceException
49
     */
50
51
    public function connect($configExternal)
52
    {
53
        $wsdl = $configExternal->get('laravel-salesforce::wsdl');
54
55
        if (empty($wsdl)) {
56
            $wsdl = __DIR__ . '/Wsdl/enterprise.wsdl.xml';
57
        }
58
59
        $username = $configExternal->get('laravel-salesforce::username');
60
        $password = $configExternal->get('laravel-salesforce::password');
61
        $token = $configExternal->get('laravel-salesforce::token');
62
63
        try {
64
            $this->sfh->createConnection($wsdl);
65
            $this->sfh->login($username, $password . $token);
66
        } catch (Exception $e) {
67
            throw new SalesforceException('Exception at Constructor' . $e->getMessage() . "\n\n" . $e->getTraceAsString());
68
        }
69
    }
70
71
    /*
72
     * Debugging functions
73
     */
74
75
    /**
76
     * @return mixed
77
     */
78
    public function dump()
79
    {
80
        return print_r($this, true);
81
    }
82
}
83