<commit_before><?php

/**
 * facebook-albums extension for Contao Open Source CMS
 *
 * @copyright  Copyright (c) 2008-2015, terminal42
 * @author     terminal42 gmbh <<EMAIL>>
 * @license    commercial
 */

namespace Terminal42\FacebookAlbumsExtension;

use Facebook\Exceptions\FacebookResponseException;
use Facebook\Exceptions\FacebookSDKException;
use Facebook\Facebook;
use Facebook\GraphNodes\GraphAlbum;

/**
 * Class FacebookAlbum
 *
 * Provide methods to handle Facebook albums.
 */
class FacebookAlbum
{

    /**
     * Account model
     * @var AccountModel
     */
    protected $accountModel;

    /**
     * Album ID
     * @var string
     */
    protected $albumId;

    /**
     * Facebook instance
     * @var Facebook
     */
    protected $facebook;

    /**
     * Meta file name
     * @var string
     */
    protected $metaFileName = 'facebook_meta';

    /**
     * Initialize the object
     *
     * @param AccountModel $accountModel
     */
    public function __construct(AccountModel $accountModel)
    {
        $this->accountModel = $accountModel;
    }

    /**
     * Get the account model
     *
     * @return AccountModel
     */
    public function getAccountModel()
    {
        return $this->accountModel;
    }

    /**
     * Set the account model
     *
     * @param AccountModel $accountModel
     */
    public function setAccountModel(AccountModel $accountModel)
    {
        $this->accountModel = $accountModel;
    }

    /**
     * Get album ID
     *
     * @return string
     */
    public function getAlbumId()
    {
        return $this->albumId;
    }

    /**
     * Set album ID
     *
     * @param string $albumId
     */
    public function setAlbumId($albumId)
    {
        $this->albumId = $albumId;
    }

    /**
     * Connect to the Facebook
     *
     * @return bool
     */
    public function connect()
    {
        try {
            $this->facebook = new Facebook(
                [
                    'app_id'                => $this->accountModel->appId,
                    'app_secret'            => $this->accountModel->appSecret,
                    'default_graph_version' => 'v2.4'
                ]
            );
        } catch (FacebookSDKException $e) {
            \System::log('Facebook SDK exception: ' . $e->getMessage(), __METHOD__, TL_ERROR);

            $this->facebook = null;
        }

        return $this->facebook !== null;
    }

    /**
     * Return true if the album is outdated and should be fetched again
     *
     * @return bool
     */
    public function isOutdated()
    {
        $album = $this->getAlbum();

        if ($album === null) {
            return false;<commit_msg>Use the v2.10 of Facebook OpenGraph<commit_after><?php

/**
 * facebook-albums extension for Contao Open Source CMS
 *
 * @copyright  Copyright (c) 2008-2015, terminal42
 * @author     terminal42 gmbh <<EMAIL>>
 * @license    commercial
 */

namespace Terminal42\FacebookAlbumsExtension;

use Facebook\Exceptions\FacebookResponseException;
use Facebook\Exceptions\FacebookSDKException;
use Facebook\Facebook;
use Facebook\GraphNodes\GraphAlbum;

/**
 * Class FacebookAlbum
 *
 * Provide methods to handle Facebook albums.
 */
class FacebookAlbum
{

    /**
     * Account model
     * @var AccountModel
     */
    protected $accountModel;

    /**
     * Album ID
     * @var string
     */
    protected $albumId;

    /**
     * Facebook instance
     * @var Facebook
     */
    protected $facebook;

    /**
     * Meta file name
     * @var string
     */
    protected $metaFileName = 'facebook_meta';

    /**
     * Initialize the object
     *
     * @param AccountModel $accountModel
     */
    public function __construct(AccountModel $accountModel)
    {
        $this->accountModel = $accountModel;
    }

    /**
     * Get the account model
     *
     * @return AccountModel
     */
    public function getAccountModel()
    {
        return $this->accountModel;
    }

    /**
     * Set the account model
     *
     * @param AccountModel $accountModel
     */
    public function setAccountModel(AccountModel $accountModel)
    {
        $this->accountModel = $accountModel;
    }

    /**
     * Get album ID
     *
     * @return string
     */
    public function getAlbumId()
    {
        return $this->albumId;
    }

    /**
     * Set album ID
     *
     * @param string $albumId
     */
    public function setAlbumId($albumId)
    {
        $this->albumId = $albumId;
    }

    /**
     * Connect to the Facebook
     *
     * @return bool
     */
    public function connect()
    {
        try {
            $this->facebook = new Facebook(
                [
                    'app_id'                => $this->accountModel->appId,
                    'app_secret'            => $this->accountModel->appSecret,
                    'default_graph_version' => 'v2.10'
                ]
            );
        } catch (FacebookSDKException $e) {
            \System::log('Facebook SDK exception: ' . $e->getMessage(), __METHOD__, TL_ERROR);

            $this->facebook = null;
        }

        return $this->facebook !== null;
    }

    /**
     * Return true if the album is outdated and should be fetched again
     *
     * @return bool
     */
    public function isOutdated()
    {
        $album = $this->getAlbum();

        if ($album === null) {
            return false;
{'fraction_non_alphanumeric': 0.11217889484383663, 'fraction_numerical': 0.006653114026982074, 'mean_word_length': 1.771121351766513, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 35, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2187036', 'n_tokens_mistral': 1584, 'n_tokens_neox': 1486, 'n_words': 362}