<commit_before><?php

namespace Wadify\StoreKeyClient;

use Aws\DynamoDb\DynamoDbClient;

class Client
{
    /**
     * @var DynamoDbClient
     */
    private $dynamoDbClient;

    /**
     * @var string
     */
    private $tableName;

    /**
     * @var string
     */
    private $attribute;

    /**
     * StoreKeyClient constructor.
     *
     * @param DynamoDbClient $dynamoDbClient
     * @param string         $tableName
     * @param string         $attribute
     */
    public function __construct(DynamoDbClient $dynamoDbClient, $tableName, $attribute)
    {
        $this->dynamoDbClient = $dynamoDbClient;
        $this->tableName = $tableName;
        $this->attribute = $attribute;
    }

    /**
     * @param $value
     *
     * @return string
     */
    private function getVariableType($value)
    {
        switch (gettype($value)) {
            case 'integer':
                return 'N';
            default:
                return 'S';
        }
    }

    /**
     * @param $key
     * @param $value
     *
     * @return int|string
     */
    private function getCastedResponse($key, $value)
    {
        if ($key === 'N') {
            return (int) $value;
        }

        return (string) $value;
    }

    /**
     * @param string $key
     * @param mixed  $value
     */
    public function store($key, $value)
    {
        $this->dynamoDbClient->putItem([
            'TableName' => $this->tableName,
            'Item' => [
                $this->attribute => [$this->getVariableType($key) => (string) $key],
                'status' => [$this->getVariableType($value) => (string) $value],
            ],
        ]);
    }

    /**
     * @param string $key
     *
     * @returns mixed
     */
    public function get($key)
    {
        $response = $this->dynamoDbClient->getItem([
            'TableName' => $this->tableName,
            'Key' => [
                $this->attribute => [$this->getVariableType($key) => (string) $key],
            ],
        ]);

        return $response['Item'];
    }

    /**
     * @param $key
     *
     * @return int|string
     */
    public function getValue($key)
    {
        $response = $this->dynamoDbClient->getItem([
            'TableName' => $this->tableName,
            'Key' => [
                $this->attribute => [$this->getVariableType($key) => (string) $key],
            ],
        ]);
        $array = $response['Item']['status'];<commit_msg>SKC-2<commit_after><?php

namespace Wadify\StoreKeyClient;

use Aws\DynamoDb\DynamoDbClient;

class Client
{
    /**
     * @var DynamoDbClient
     */
    private $dynamoDbClient;

    /**
     * @var string
     */
    private $tableName;

    /**
     * @var string
     */
    private $attribute;

    /**
     * StoreKeyClient constructor.
     *
     * @param DynamoDbClient $dynamoDbClient
     * @param string         $tableName
     * @param string         $attribute
     */
    public function __construct(DynamoDbClient $dynamoDbClient, $tableName, $attribute)
    {
        $this->dynamoDbClient = $dynamoDbClient;
        $this->tableName = $tableName;
        $this->attribute = $attribute;
    }

    /**
     * @param $value
     *
     * @return string
     */
    private function getVariableType($value)
    {
        switch (gettype($value)) {
            case 'integer':
                return 'N';
            default:
                return 'S';
        }
    }

    /**
     * @param $key
     * @param $value
     *
     * @return int|string
     */
    private function getCastedResponse($key, $value)
    {
        if ($key === 'N') {
            return (int) $value;
        }

        return (string) $value;
    }

    /**
     * @param string $key
     * @param mixed  $value
     */
    public function store($key, $value)
    {
        $this->dynamoDbClient->putItem([
            'TableName' => $this->tableName,
            'Item' => [
                $this->attribute => [$this->getVariableType($key) => (string) $key],
                'status' => [$this->getVariableType($value) => (string) $value],
            ],
        ]);
    }

    /**
     * @deprecated deprecated since version 2.0
     *
     * @param string $key
     *
     * @returns mixed
     */
    public function get($key)
    {
        $response = $this->dynamoDbClient->getItem([
            'TableName' => $this->tableName,
            'Key' => [
                $this->attribute => [$this->getVariableType($key) => (string) $key],
            ],
        ]);

        return $response['Item'];
    }

    /**
     * @param $key
     *
     * @return int|string
     */
    public function getValue($key)
    {
        $response = $this->dynamoDbClient->getItem([
            'TableName' => $this->tableName,
            'Key' => [
                $this->attribute => [$this->getVariableType($key) => (string) $key],
            ],
        ]);
        $array = $response['Item']['status'];
{'fraction_non_alphanumeric': 0.15348837209302327, 'fraction_numerical': 0.0006066734074823053, 'mean_word_length': 1.611404435058078, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5298905', 'n_tokens_mistral': 1526, 'n_tokens_neox': 1488, 'n_words': 276}