<commit_before><?php

namespace Artesaos\SEOTools;

use Artesaos\SEOTools\Contracts\TwitterCards as TwitterCardsContract;

class TwitterCards implements TwitterCardsContract
{
    /**
     * @var string
     */
    protected $prefix = 'twitter:';

    /**
     * @var array
     */
    protected $html = [];

    /**
     * @var array
     */
    protected $values = [];

    /**
     * @var array
     */
    protected $images = [];

    /**
     * @param array $defaults
     */
    public function __construct(array $defaults)
    {
        $this->values = $defaults;
    }

    /**
     * @return string
     */
    public function generate()
    {
        $this->eachValue($this->values);
        $this->eachValue($this->images, 'images');

        return implode(PHP_EOL, $this->html);
    }

    /**
     * Make tags.
     *
     * @param array       $properties
     * @param null|string $prefix
     *
     * @return void
     */
    protected function eachValue(array $values, $prefix = null)
    {
        foreach ($values as $key => $value):
            if (is_array($value)):
                $this->eachValue($value, $key); else:
                if (is_numeric($key)):
                    $key = $prefix.$key; elseif (is_string($prefix)):
                    $key = $prefix.':'.$key;
        endif;

        $this->html[] = $this->makeTag($key, $value);
        endif;
        endforeach;
    }

    /**
     * @param string $key
     * @param string $values
     *
     * @return string
     */
    private function makeTag($key, $value)
    {
        return '<meta name="'.$this->prefix.strip_tags($key).'" content="'.strip_tags($value).'" />';
    }

    /**
     * @oaram string $key
     * @oaram string|array $key
     *
     * @return TwitterCardsContract
     */
    public function addValue($key, $value)
    {
        $this->values[$key] = $value;

        return $this;
    }

    /**
     * @param string $title
     *
     * @return TwitterCardsContract
     */
    public function setTitle($title)
    {
        return $this->addValue('title', $title);
    }

    /**
     * @param string $type
     *
     * @return TwitterCardsContract
     */
    public function setType($type)
    {
        return $this->addValue('type', $type);
    }

    /**
     * @param string $site
     *
     * @return TwitterCardsContract
     */
    public function setSite($site)
    {
        return $this->addValue('site', $site);
    }

    /**
     * @param string $description
     *
     * @return TwitterCardsContract
     */
    public function setDescription($description)
    {
        return $this->addValue('description', $description);
    }

    /**
     * @param string $description
     *
     * @return TwitterCardsContract
     */
    public function setUrl($url)
    {
        return $this->addValue('url', $url);
    }

    /**
     * @param string|array $image
     *
     * @return TwitterCardsContract
     */
    public function addImage($image)
    {
        foreach ((array) $image as $url):
            $this->images[] = $url;
        endforeach;

        return $this;
    }

    /**
     * @param string|array $images
     *
     * @return TwitterCardsContract
     */
    public function setImages($images)
    {
        $this->images = [];

        return $this->addImage($images);
    }
}
<commit_msg>tyopofix<commit_after><?php

namespace Artesaos\SEOTools;

use Artesaos\SEOTools\Contracts\TwitterCards as TwitterCardsContract;

class TwitterCards implements TwitterCardsContract
{
    /**
     * @var string
     */
    protected $prefix = 'twitter:';

    /**
     * @var array
     */
    protected $html = [];

    /**
     * @var array
     */
    protected $values = [];

    /**
     * @var array
     */
    protected $images = [];

    /**
     * @param array $defaults
     */
    public function __construct(array $defaults)
    {
        $this->values = $defaults;
    }

    /**
     * @return string
     */
    public function generate()
    {
        $this->eachValue($this->values);
        $this->eachValue($this->images, 'images');

        return implode(PHP_EOL, $this->html);
    }

    /**
     * Make tags.
     *
     * @param array $values
     * @param null|string $prefix
     *
     * @internal param array $properties
     */
    protected function eachValue(array $values, $prefix = null)
    {
        foreach ($values as $key => $value):
            if (is_array($value)):
                $this->eachValue($value, $key); else:
                if (is_numeric($key)):
                    $key = $prefix.$key; elseif (is_string($prefix)):
                    $key = $prefix.':'.$key;
        endif;

        $this->html[] = $this->makeTag($key, $value);
        endif;
        endforeach;
    }

    /**
     * @param string $key
     * @param $value
     * @return string
     *
     * @internal param string $values
     */
    private function makeTag($key, $value)
    {
        return '<meta name="'.$this->prefix.strip_tags($key).'" content="'.strip_tags($value).'" />';
    }

    /**
     * @param string $key
     * @param string|array $value
     *
     * @return TwitterCardsContract
     */
    public function addValue($key, $value)
    {
        $this->values[$key] = $value;

        return $this;
    }

    /**
     * @param string $title
     *
     * @return TwitterCardsContract
     */
    public function setTitle($title)
    {
        return $this->addValue('title', $title);
    }

    /**
     * @param string $type
     *
     * @return TwitterCardsContract
     */
    public function setType($type)
    {
        return $this->addValue('type', $type);
    }

    /**
     * @param string $site
     *
     * @return TwitterCardsContract
     */
    public function setSite($site)
    {
        return $this->addValue('site', $site);
    }

    /**
     * @param string $description
     *
     * @return TwitterCardsContract
     */
    public function setDescription($description)
    {
        return $this->addValue('description', $description);
    }

    /**
     * @param string $url
     *
     * @return TwitterCardsContract
     */
    public function setUrl($url)
    {
        return $this->addValue('url', $url);
    }

    /**
     * @param string|array $image
     *
     * @return TwitterCardsContract
     */
    public function addImage($image)
    {
        foreach ((array) $image as $url):
            $this->images[] = $url;
        endforeach;

        return $this;
    }

    /**
     * @param string|array $images
     *
     * @return TwitterCardsContract
     */
    public function setImages($images)
    {
        $this->images = [];

        return $this->addImage($images);
    }
}

{'fraction_non_alphanumeric': 0.1483467381590706, 'fraction_numerical': 0.0, 'mean_word_length': 1.8002502085070893, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 45, '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': '1529162', 'n_tokens_mistral': 2048, 'n_tokens_neox': 1997, 'n_words': 413}