<commit_before><?php

namespace CultuurNet\UDB3\Event;

use CultuurNet\UDB3\Category;
use CultuurNet\UDB3\Model\ValueObject\Taxonomy\Category\Category as Udb3ModelCategory;
use InvalidArgumentException;

final class EventType extends Category
{
    const DOMAIN = 'eventtype';

    public function __construct(string $id, string $label)
    {
        parent::__construct($id, $label, self::DOMAIN);
    }

    public static function fromJSONLDEvent(string $eventString): ?EventType
    {
        $event = json_decode($eventString);
        foreach ($event->terms as $term) {
            if ($term->domain == self::DOMAIN) {
                return new self($term->id, $term->label);
            }
        }
        return null;
    }

    public static function fromUdb3ModelCategory(Udb3ModelCategory $category): EventType
    {
        $label = $category->getLabel();

        if (is_null($label)) {
            throw new InvalidArgumentException('Category label is required.');
        }

        return new self(
            $category->getId()->toString(),
            $label->toString()
        );
    }

    public static function deserialize(array $data): EventType<commit_msg>Fix json_decode warning<commit_after><?php

namespace CultuurNet\UDB3\Event;

use CultuurNet\UDB3\Category;
use CultuurNet\UDB3\Model\ValueObject\Taxonomy\Category\Category as Udb3ModelCategory;
use InvalidArgumentException;

final class EventType extends Category
{
    const DOMAIN = 'eventtype';

    public function __construct(string $id, string $label)
    {
        parent::__construct($id, $label, self::DOMAIN);
    }

    public static function fromJSONLDEvent(string $eventString): ?EventType
    {
        $event = json_decode($eventString, false);
        foreach ($event->terms as $term) {
            if ($term->domain == self::DOMAIN) {
                return new self($term->id, $term->label);
            }
        }
        return null;
    }

    public static function fromUdb3ModelCategory(Udb3ModelCategory $category): EventType
    {
        $label = $category->getLabel();

        if (is_null($label)) {
            throw new InvalidArgumentException('Category label is required.');
        }

        return new self(
            $category->getId()->toString(),
            $label->toString()
        );
    }

    public static function deserialize(array $data): EventType
{'fraction_non_alphanumeric': 0.11288292068820814, 'fraction_numerical': 0.005035669324381032, 'mean_word_length': 2.6904024767801857, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '3359582', 'n_tokens_mistral': 671, 'n_tokens_neox': 656, 'n_words': 154}