SFCreation

class SFCreation

Class SFCreation

Represents an object create response from SalesForce.

Properties

protected string $_id
protected bool $_success
protected array $_errors

Methods

public __construct(stdClass $data) SFCreation constructor.
public string getId() No description
public bool wasSuccessful() No description
public array getErrors() No description

Details

at line 39

__construct()

public __construct(stdClass $data)

SFCreation constructor.

Requires the $data argument to contain specific properties: * string id * bool success * array errors

Parameters

stdClass $data A successful create response object from SalesForce
at line 60

getId()

public string getId()

Return Value

string
at line 67

wasSuccessful()

public bool wasSuccessful()

Return Value

bool
at line 74

getErrors()

public array getErrors()

Return Value

array

Source code

<?php

namespace SFClient\SalesForce;

/**
 * Class SFCreation
 *
 * Represents an object create response from SalesForce.
 *
 * @package SFClient\SalesForce
 */
class SFCreation {

  /**
   * @var string
   */
  protected $_id;

  /**
   * @var bool
   */
  protected $_success;

  /**
   * @var array
   */
  protected $_errors;

  /**
   * SFCreation constructor.
   *
   * Requires the $data argument to contain specific properties:
   * * string id
   * * bool success
   * * array errors
   *
   * @param \stdClass $data A successful create response object from SalesForce
   */
  public function __construct(\stdClass $data) {
    if (!isset($data->id)) {
      throw new \InvalidArgumentException('Data is missing an id property.');
    }

    if (!isset($data->success)) {
      throw new \InvalidArgumentException('Data is messing a success property.');
    }

    if (!isset($data->errors)) {
      throw new \InvalidArgumentException('Data is missing an errors property.');
    }

    $this->_id = $data->id;
    $this->_success = (bool) $data->success;
    $this->_errors = $data->errors;
  }

  /**
   * @return string
   */
  public function getId(): string {
    return $this->_id;
  }

  /**
   * @return bool
   */
  public function wasSuccessful(): bool {
    return $this->_success;
  }

  /**
   * @return array
   */
  public function getErrors(): array {
    return $this->_errors;
  }
}