protected function formatPutItemCommandOptions(EntityInterface $entity, $mustExist)
    {
        $attributes = array($entity::getHashKeyAttribute() => $entity->getHashKey());
        $rangeKeyAttribute = $entity::getRangeKeyAttribute();
        if ($rangeKeyAttribute) {
            $attributes[$rangeKeyAttribute] = $entity->getRangeKey();
        }

        $commandOptions = array(
            'TableName'              => $this->getEntityTable($entity),
            'Item'                   => $this->formatEntityAttributes($entity),
            'ReturnConsumedCapacity' => $this->returnConsumedCapacity,
        );

        // Adds conditions based on whether items is being added or updated.
        if ($entity::enforceEntityIntegrity()) {
            if ($mustExist) {
                $entityClass = get_class($entity);
                $commandOptions['Expected'] = $this->formatAttributes($entityClass, $attributes, Attribute::FORMAT_EXPECTED);
            } else {
                foreach ($attributes as $attribute => $value) {
                    $commandOptions['Expected'][$attribute] = array('Exists' => false);
                }
            }
        }

        return $commandOptions;
    }