<commit_before><?php

/*
 * This file is part of the SimplePhoto package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace SimplePhoto\Storage;

use Aws\S3\S3Client;

/**
 * @author <NAME> <<EMAIL>>
 */
class AwsS3Storage implements StorageInterface
{
    protected $client;

    protected $bucket;

    protected $directory;

    protected $acl = 'public-read';

    public function __construct(S3Client $s3Client, array $options = array())
    {
        $this->client = $s3Client;

        foreach ($options as $option => $value) {
            switch ($option) {
                case 'bucket':
                    $this->bucket = $value;
                    break;
                case 'directory':
                    $this->directory = $value;
                    break;
                case 'acl':
                    $this->acl = $value;
                    break;
            }
        }
    }

    /**
     * {@inheritDoc}
     */
    public function upload($file, $name, array $options = array())
    {
        try {
            $this->client->putObject($this->getOptions($file, array(
                'SourceFile' => $file
            )));

            return $this->normalizePath($file, false);

        } catch (\Exception $e) {
            return false;
        }
    }

    /**
     * {@inheritDoc}
     */
    public function getInfo($file)
    {

    }

    /**
     * {@inheritDoc}
     */
    public function deletePhoto($file)
    {
        return $this->client->deleteObject($this->getOptions($file));
    }

    /**
     * {@inheritDoc}
     */
    public function getPhotoPath($file)
    {
        return $this->normalizePath($file);
    }

    /**<commit_msg>Updated getInfo() for AwsS3 Storage<commit_after><?php

/*
 * This file is part of the SimplePhoto package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace SimplePhoto\Storage;

use Aws\S3\S3Client;

/**
 * @author <NAME> <<EMAIL>>
 */
class AwsS3Storage implements StorageInterface
{
    protected $client;

    protected $bucket;

    protected $directory;

    protected $acl = 'public-read';

    public function __construct(S3Client $s3Client, array $options = array())
    {
        $this->client = $s3Client;

        foreach ($options as $option => $value) {
            switch ($option) {
                case 'bucket':
                    $this->bucket = $value;
                    break;
                case 'directory':
                    $this->directory = $value;
                    break;
                case 'acl':
                    $this->acl = $value;
                    break;
            }
        }
    }

    /**
     * {@inheritDoc}
     */
    public function upload($file, $name, array $options = array())
    {
        try {
            $this->client->putObject($this->getOptions($file, array(
                'SourceFile' => $file
            )));

            return $this->normalizePath($file, false);

        } catch (\Exception $e) {
            return false;
        }
    }

    /**
     * {@inheritDoc}
     */
    public function getInfo($file)
    {
        $result = $this->client->headObject($this->getOptions($file));

        return array(
            'file_size' => $result['ContentLength']
        );
    }

    /**
     * {@inheritDoc}
     */
    public function deletePhoto($file)
    {
        return $this->client->deleteObject($this->getOptions($file));
    }

    /**
     * {@inheritDoc}
     */
    public function getPhotoPath($file)
    {
        return $this->normalizePath($file);
    }

    /**
{'fraction_non_alphanumeric': 0.13621964097148892, 'fraction_numerical': 0.0034318901795142554, 'mean_word_length': 1.66268446943078, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 47, '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': '7193663', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1035, 'n_words': 248}