<commit_before><?php

namespace Mapbender\SearchBundle\Entity;

use Eslider\Entity\UniqueBaseEntity;

/**
 * Class StyleMap
 *
 * @package Mapbender\DataSourceBundle\Entity
 * @author  <NAME> <<EMAIL>>
 */
class StyleMap extends UniqueBaseEntity
{

    /* @var Style[] Styles */
    protected $styles;

    /** @var string userId **/
    protected $userId;

    /**
     * @return string
     */
    public function getUserId()
    {
        return $this->userId;
    }

    /**
     * @param string $userId
     */
    public function setUserId($userId)
    {
        $this->userId = $userId;
    }

    /**
     * @return Style[]
     */
    public function getStyles()
    {
        return $this->styles;
    }

    /**
     * @return Style
     */
    public function getStyle($name = 'default')
    {
        return $this->styles[ $name ];
    }


    /**
     * @param Style  $style
     * @param string $name
     * @return Style
     */
    public function setStyle(Style $style, $name = 'default')
    {
        $this->styles[ $name ] = $style;
        return $style;
    }


    /**
     * @param Style $style
     * @return Style|boolean
     */
    public function removeStyle(Style $style)
    {
        $result = false;
        foreach ($this->styles as $key => $value) {
            if ($value->getId() == $style->getId()) {
                $result = $this->styles[ $key ];
                unset($this->styles[ $key ]);
                return $result;
            }
        }
        return $result;
    }

    /**
     * @param string $name
     * @return Style|boolean
     */
    public function removeStyleByName($name)
    {
        $result = false;
        foreach ($this->styles as $key => $value) {
            if ($value->getName() == $name) {
                $result = $this->styles[ $key ];
                unset($this->styles[ $key ]);
                return $result;
            }
        }
        return $result;
    }

    public function fill(array &$data)
    {
        parent::fill($data);
    }


}<commit_msg>Add addStyle Method to StyleMap Entity<commit_after><?php

namespace Mapbender\SearchBundle\Entity;

use Eslider\Entity\UniqueBaseEntity;

/**
 * Class StyleMap
 *
 * @package Mapbender\DataSourceBundle\Entity
 * @author  <NAME> <<EMAIL>>
 */
class StyleMap extends UniqueBaseEntity
{

    /* @var Style[] Styles */
    protected $styles;

    /** @var string userId * */
    protected $userId;

    public function __construct(array &$data = null)
    {
        $this->styles = array();
        parent::__construct($data);
    }

    /**
     * @return string
     */
    public function getUserId()
    {
        return $this->userId;
    }

    /**
     * @param string $userId
     */
    public function setUserId($userId)
    {
        $this->userId = $userId;
    }

    /**
     * @return Style[]
     */
    public function getStyles()
    {
        return $this->styles;
    }

    /**
     * @return Style
     */
    public function getStyle($name = 'default')
    {
        return $this->styles[ $name ];
    }


    /**
     * @param Style  $style
     * @param string $name
     * @return Style
     */
    public function setStyle(Style $style, $name = 'default')
    {
        $this->styles[ $name ] = $style;
        return $style;
    }


    /**
     * @param Style $style
     * @return Style|boolean
     */
    public function removeStyle(Style $style)
    {
        $result = false;
        foreach ($this->styles as $key => $value) {
            if ($value->getId() == $style->getId()) {
                $result = $this->styles[ $key ];
                unset($this->styles[ $key ]);
                return $result;
            }
        }
        return $result;
    }

    /**
     * @param string $name
     * @return Style|boolean
     */
    public function removeStyleByName($name)
    {
        $result = false;
        foreach ($this->styles as $key => $value) {
            if ($value->getName() == $name) {
                $result = $this->styles[ $key ];
                unset($this->styles[ $key ]);
                return $result;
            }
        }
        return $result;
    }

    /**
     * @param string $name
     * @param Style  $map
     * @return StyleMap
     */
    public function addStyle($name, $map)
    {
        $this->styles[ $name ] = $map;
        return $this;
    }


    public function fill(array &$data)
    {
        parent::fill($data);
    }


}
{'fraction_non_alphanumeric': 0.1463797354853172, 'fraction_numerical': 0.0, 'mean_word_length': 1.6607036374478235, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 43, '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': '3698236', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1325, 'n_words': 302}