protected function loadDataFromItem(DynamoDbClient $dynamodb, array $options)
    {
        $field = $options['key_field'] ?? 'key';
        expect_type($field, 'string', \BadMethodCallException::class);

        $key = $options['key_value'];
        expect_type($key, 'string', \BadMethodCallException::class);

        try {
            $result = $dynamodb->getItem([
                'TableName' => $options["table"],
                'Key' => [
                    $field => ['S' => $key]
                ]
            ]);
            
            if (!isset($result['Item']) && !(bool)($options['optional'] ?? false)) {
                throw new LoadException("Failed to load '{$options['key_value']}' configuration from DynamoDB: "
                    . "No item found with $field '$key'");
            }
            
            $item = isset($result['Item']) ? $result['Item'] : null;
        } catch (DynamoDbException $e) {
            if (!(bool)($options['optional'] ?? false)) {
                throw new LoadException("Failed to load '{$options['key_value']}' configuration from DynamoDB", 0, $e);
            }
        }

        if (!isset($item)) {
            return [];
        }
        
        $marshaler = new Marshaler();
        $data = $marshaler->unmarshalItem($item);
        
        return $this->mapData($data, $options);
    }
protected function loadDataFromItem(DynamoDbClient $dynamodb, array $options)
    {
        $field = $options['key_field'] ?? 'key';
        expect_type($field, 'string', \BadMethodCallException::class);

        $key = $options['key_value'];
        expect_type($key, 'string', \BadMethodCallException::class);

        try {
            $result = $dynamodb->getItem([
                'TableName' => $options["table"],
                'Key' => [
                    $field => ['S' => $key]
                ]
            ]);
            
            if (!isset($result['Item']) && !(bool)($options['optional'] ?? false)) {
                throw new LoadException("Failed to load '{$options['key_value']}' configuration from DynamoDB: "
                    . "No item found with $field '$key'");
            }
            
            $item = isset($result['Item']) ? $result['Item'] : null;
        } catch (DynamoDbException $e) {
            if (!(bool)($options['optional'] ?? false)) {
                throw new LoadException("Failed to load '{$options['key_value']}' configuration from DynamoDB", 0, $e);
            }
        }

        if (!isset($item)) {
            return [];
        }
        
        $marshaler = new Marshaler();
        $data = $marshaler->unmarshalItem($item);
        
        return $this->mapData($data, $options);
    }
protected function loadDataFromItem ( DynamoDbClient $ dynamodb , array $ options ) { $ field = $ options [ 'key_field' ] ?? 'key' ; expect_type ( $ field , 'string' , \ BadMethodCallException :: class ) ; $ key = $ options [ 'key_value' ] ; expect_type ( $ key , 'string' , \ BadMethodCallException :: class ) ; try { $ result = $ dynamodb -> getItem ( [ 'TableName' => $ options [ "table" ] , 'Key' => [ $ field => [ 'S' => $ key ] ] ] ) ; if ( ! isset ( $ result [ 'Item' ] ) && ! ( bool ) ( $ options [ 'optional' ] ?? false ) ) { throw new LoadException ( "Failed to load '{$options['key_value']}' configuration from DynamoDB: " . "No item found with $field '$key'" ) ; } $ item = isset ( $ result [ 'Item' ] ) ? $ result [ 'Item' ] : null ; } catch ( DynamoDbException $ e ) { if ( ! ( bool ) ( $ options [ 'optional' ] ?? false ) ) { throw new LoadException ( "Failed to load '{$options['key_value']}' configuration from DynamoDB" , 0 , $ e ) ; } } if ( ! isset ( $ item ) ) { return [ ] ; } $ marshaler = new Marshaler ( ) ; $ data = $ marshaler -> unmarshalItem ( $ item ) ; return $ this -> mapData ( $ data , $ options ) ; }
Query Dynamo DB table loading all settings from a single item.

@param DynamoDbClient $dynamodb  DB connection
@param array          $options
@return array|mixed
Query Dynamo DB table loading all settings from a single item .