Esempio n. 1
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.');
     }
 }
Esempio n. 2
0
 public function testConstructorSetsValuesWhenItemContainsTable()
 {
     $item = new Item(['id' => ['S' => 'foo']], 'table');
     $putRequest = new PutRequest($item);
     $this->assertSame($item->toArray(), $putRequest->getItem()->toArray());
 }