<commit_before><?php

namespace Crew\Unsplash;

class Photo extends Endpoint
{
    private $photographer;
    
    /**
     * Retrieve the a photo object from the ID specified
     *
     * @param  string $id ID of the photo
     * @return Photo
     */
    public static function find($id)
    {
        $photo = json_decode(self::get("photos/{$id}")->getBody(), true);
        
        return new self($photo);
    }

    /**
     * Retrieve all the photos on a specific page.
     * Returns an ArrayObject that contains Photo objects.
     * 
     * @param  integer $page Page from which the photos need to be retrieve
     * @param  integer $per_page Number of element in a page
     * @return ArrayObject of Photos
     */
    public static function all($page = 1, $per_page = 10)
    {
        $photos = self::get("photos", ['query' => ['page' => $page, 'per_page' => $per_page]]);

        $photosArray = self::getArray($photos->getBody(), get_called_class());

        return new ArrayObject($photosArray, $photos->getHeaders());
    }


    /**
     * Retrieve a single page from the list of the curated photos (front-page’s photos).
     * Returns an ArrayObject that contains Photo objects.
     *
     * @param  integer $page Page from which the photos need to be retrieve
     * @param  integer $per_page Number of element in a page
     * @return ArrayObject of Photos
     */
    public static function curated($page = 1, $per_page = 10)
    {
        $photos = self::get("photos/curated", ['query' => ['page' => $page, 'per_page' => $per_page]]);

        $photosArray = self::getArray($photos->getBody(), get_called_class());

        return new ArrayObject($photosArray, $photos->getHeaders());
    }

    /**
     * Retrieve all the photos on a specific page depending on search results
     * Returns ArrayObject that contain Photo object.
     *
     * @param  string    $search Retrieve photos matching the search term.
     * @param  integer $category Retrieve photos matching the category ID
     * @param  integer $page Page from which the photos need to be retrieved
     * @param  integer $per_page Number of elements on a page
     * @return ArrayObject of Photos
     */
    public static function search($search, $category = null, $page = 1, $per_page = 10)
    {
        $photos = self::get(
            "photos/search", [
                'query' => [
                    'query' => $search,
                    'category' => $category,
                    'page' => $page,
                    'per_page' => $per_page
                ]
            ]
        );

        $photosArray = self::getArray($photos->getBody(), get_called_class());

        return new ArrayObject($photosArray, $photos->getHeaders());
    }

    /**
     * Create a new photo. The user needs to connect their account and authorize the write_photo permission scope.
     * 
     * @param  string $filePath Path of the file to upload
     * @return Photo
     */
    public static function create($filePath)
    {
        if (!file_exists($filePath)) {<commit_msg>Added orientation parameters to /photos/search (#41)<commit_after><?php

namespace Crew\Unsplash;

class Photo extends Endpoint
{
    private $photographer;
    
    /**
     * Retrieve the a photo object from the ID specified
     *
     * @param  string $id ID of the photo
     * @return Photo
     */
    public static function find($id)
    {
        $photo = json_decode(self::get("photos/{$id}")->getBody(), true);
        
        return new self($photo);
    }

    /**
     * Retrieve all the photos on a specific page.
     * Returns an ArrayObject that contains Photo objects.
     * 
     * @param  integer $page Page from which the photos need to be retrieve
     * @param  integer $per_page Number of element in a page
     * @return ArrayObject of Photos
     */
    public static function all($page = 1, $per_page = 10)
    {
        $photos = self::get("photos", ['query' => ['page' => $page, 'per_page' => $per_page]]);

        $photosArray = self::getArray($photos->getBody(), get_called_class());

        return new ArrayObject($photosArray, $photos->getHeaders());
    }


    /**
     * Retrieve a single page from the list of the curated photos (front-page’s photos).
     * Returns an ArrayObject that contains Photo objects.
     *
     * @param  integer $page Page from which the photos need to be retrieve
     * @param  integer $per_page Number of element in a page
     * @return ArrayObject of Photos
     */
    public static function curated($page = 1, $per_page = 10)
    {
        $photos = self::get("photos/curated", ['query' => ['page' => $page, 'per_page' => $per_page]]);

        $photosArray = self::getArray($photos->getBody(), get_called_class());

        return new ArrayObject($photosArray, $photos->getHeaders());
    }

    /**
     * Retrieve all the photos on a specific page depending on search results
     * Returns ArrayObject that contain Photo object.
     *
     * @param  string    $search Retrieve photos matching the search term.
     * @param  integer $category Retrieve photos matching the category ID
     * @param  integer $page Page from which the photos need to be retrieved
     * @param  integer $per_page Number of elements on a page
     * @return ArrayObject of Photos
     */
    public static function search($search, $category = null, $orientation = null, $page = 1, $per_page = 10)
    {
        $photos = self::get(
            "photos/search", [
                'query' => [
                    'query' => $search,
                    'category' => $category,
                    'orientation' => $orientation,
                    'page' => $page,
                    'per_page' => $per_page
                ]
            ]
        );

        $photosArray = self::getArray($photos->getBody(), get_called_class());

        return new ArrayObject($photosArray, $photos->getHeaders());
    }

    /**
     * Create a new photo. The user needs to connect their account and authorize the write_photo permission scope.
     * 
     * @param  string $filePath Path of the file to upload
     * @return Photo
     */
    public static function create($filePath)
    {
        if (!file_exists($filePath)) {
{'fraction_non_alphanumeric': 0.11361817890862538, 'fraction_numerical': 0.003200512081933109, 'mean_word_length': 2.324468085106383, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 40, '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': '4959115', 'n_tokens_mistral': 1790, 'n_tokens_neox': 1677, 'n_words': 585}