<commit_before><?php
/**
 * Altru.php
 *
 * @package Embera
 * @author <NAME> <<EMAIL>>
 * @link   http://www.michael-pratt.com/
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Embera\Provider;

use Embera\Url;

/**
 * altrulabs.com Provider
 *
 * @link https://app.altrulabs.com
 *
 */
class Altru extends ProviderAdapter implements ProviderInterface
{
    /** inline {@inheritdoc} */
    protected $endpoint = 'https://api.altrulabs.com/api/v1/social/oembed?format=json';

    /** inline {@inheritdoc} */
    protected static $hosts = [
        'app.altrulabs.com'
    ];

    /** inline {@inheritdoc} */
    protected $httpsSupport = true;

    /** inline {@inheritdoc} */
    public function validateUrl(Url $url)
    {
        return (bool) (
            preg_match('~\.com/(?:[^/]+)/(?:[^/]+)/?\?answer_id=(?:[0-9]+)~i', (string) $url) ||
            preg_match('~\.com/player/([0-9]+)~i', (string) $url)
        );
    }

    /** inline {@inheritdoc} */
    public function normalizeUrl(Url $url)
    {
        $url->convertToHttps();
        return $url;
    }

    /** inline {@inheritdoc} */
    public function getFakeResponse()
    {
        if (preg_match('~answer_id=([0-9]+)~i', (string) $this->url, $matches)) {
            $embedUrl = 'https://api.altrulabs.com/api/v1/social/embed_player/' . $matches['1'];
        } else if (preg_match('~/player/([0-9]+)~i', (string) $this->url, $matches)) {
            $embedUrl = 'https://api.altrulabs.com/api/v1/social/embed_player/' . $matches['1'];
        }

        $attr = [];
        $attr[] = 'width="{width}"';
        $attr[] = 'height="{height}"';
        $attr[] = 'src="' . $embedUrl . '"';
        $attr[] = 'frameborder="0"';
        $attr[] = 'allow="autoplay; encrypted-media"';
        $attr[] = 'allowfullscreen';

        return [
            'type' => 'video',
            'provider_name' => 'Altru',
            'provider_url' => 'https://www.altrulabs.com',
            'title' => 'Unknown title',
            'html' => '<iframe ' . implode(' ', $attr). '></iframe>',
        ];
    }

}
<commit_msg>Added missing vars on Altru provider<commit_after><?php
/**
 * Altru.php
 *
 * @package Embera
 * @author <NAME> <<EMAIL>>
 * @link   http://www.michael-pratt.com/
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Embera\Provider;

use Embera\Url;

/**
 * altrulabs.com Provider
 *
 * @link https://app.altrulabs.com
 *
 */
class Altru extends ProviderAdapter implements ProviderInterface
{
    /** inline {@inheritdoc} */
    protected $endpoint = 'https://api.altrulabs.com/api/v1/social/oembed?format=json';

    /** inline {@inheritdoc} */
    protected static $hosts = [
        'app.altrulabs.com'
    ];

    /** inline {@inheritdoc} */
    protected $httpsSupport = true;

    /** inline {@inheritdoc} */
    public function validateUrl(Url $url)
    {
        return (bool) (
            preg_match('~\.com/(?:[^/]+)/(?:[^/]+)/?\?answer_id=(?:[0-9]+)~i', (string) $url) ||
            preg_match('~\.com/player/([0-9]+)~i', (string) $url)
        );
    }

    /** inline {@inheritdoc} */
    public function normalizeUrl(Url $url)
    {
        $url->convertToHttps();
        return $url;
    }

    /** inline {@inheritdoc} */
    public function getFakeResponse()
    {
        $embedUrl = '';
        if (preg_match('~answer_id=([0-9]+)~i', (string) $this->url, $matches)) {
            $embedUrl = 'https://api.altrulabs.com/api/v1/social/embed_player/' . $matches['1'];
        } else if (preg_match('~/player/([0-9]+)~i', (string) $this->url, $matches)) {
            $embedUrl = 'https://api.altrulabs.com/api/v1/social/embed_player/' . $matches['1'];
        }

        $attr = [];
        $attr[] = 'width="{width}"';
        $attr[] = 'height="{height}"';
        $attr[] = 'src="' . $embedUrl . '"';
        $attr[] = 'frameborder="0"';
        $attr[] = 'allow="autoplay; encrypted-media"';
        $attr[] = 'allowfullscreen';

        return [
            'type' => 'video',
            'provider_name' => 'Altru',
            'provider_url' => 'https://www.altrulabs.com',
            'title' => 'Unknown title',
            'html' => '<iframe ' . implode(' ', $attr). '></iframe>',
        ];
    }

}

{'fraction_non_alphanumeric': 0.20699840945239717, 'fraction_numerical': 0.006362190411270166, 'mean_word_length': 2.368018362662586, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 29, 'https://': 10, 'lorem ipsum': 0, 'www.': 4, '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': '6486046', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1467, 'n_words': 272}