예제 #1
0
 /**
  * Constructs a new put request
  *
  * @param Item   $item      The item to put into DynamoDB
  * @param string $tableName The name of the table which has the item
  *
  * @throw InvalidArgumentException if the table name is not provided
  */
 public function __construct(Item $item, $tableName = null)
 {
     $this->item = $item;
     $this->tableName = $tableName ?: $item->getTableName();
     if (!$this->tableName) {
         throw new InvalidArgumentException('A table name is required to create a PutRequest.');
     }
 }
예제 #2
0
 /**
  * Constructs a new put request
  *
  * @param array|Item $item      The item to put into DynamoDB
  * @param string     $tableName The name of the table which has the item
  *
  * @throw InvalidArgumentException if the table name is not provided
  */
 public function __construct($item, $tableName = null)
 {
     if ($item instanceof Item) {
         $this->item = $item->toArray();
         $this->tableName = $tableName ?: $item->getTableName();
     } elseif (is_array($item)) {
         $this->item = $item;
         $this->tableName = $tableName;
     } else {
         throw new InvalidArgumentException('The item must be an array or an Item object.');
     }
     if (!$this->tableName) {
         throw new InvalidArgumentException('A table name is required to create a PutRequest.');
     }
 }