<commit_before><?php

namespace SmartCore\Bundle\MediaBundle\Service;

use Doctrine\ORM\EntityManager;
use SmartCore\Bundle\MediaBundle\Entity\File;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

class MediaCloudService
{
    use ContainerAwareTrait;

    /**
     * @var EntityManager
     */
    protected $em;

    /**
     * @var CollectionService[]
     */
    protected $collections;

    /**
     * @param ContainerInterface $container
     */
    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
        $this->em        = $container->get('doctrine.orm.entity_manager');
    }

    /**
     * @param int $id
     * @return CollectionService
     */
    public function getCollection($id)
    {
        if (!isset($this->collections[$id])) {
            $this->collections[$id] = new CollectionService($this->container, $id);
        }

        return $this->collections[$id];
    }

    /**
     * Получить ссылку на файл.
     *
     * @param int $id
     * @param string $filer
     * @return string
     *
     * @todo кеширование.
     */
    public function getFileUrl($id, $filer = null)
    {
        /** @var File $file */
        $file = $this->em->getRepository('SmartMediaBundle:File')->find($id);

        if (empty($file)) {
            return null;
        }

        return $this->getCollection($file->getCollection()->getId())->get($id, $filer);
    }

    public function createCollection()
    {
        // @todo
    }

    public function removeCollection()
    {
        // @todo
    }<commit_msg>security fix<commit_after><?php

namespace SmartCore\Bundle\MediaBundle\Service;

use Doctrine\ORM\EntityManager;
use SmartCore\Bundle\MediaBundle\Entity\File;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

class MediaCloudService
{
    use ContainerAwareTrait;

    /**
     * @var EntityManager
     */
    protected $em;

    /**
     * @var CollectionService[]
     */
    protected $collections;

    /**
     * @param ContainerInterface $container
     */
    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
        $this->em        = $container->get('doctrine.orm.entity_manager');
    }

    /**
     * @param int $id
     * @return CollectionService
     */
    public function getCollection($id)
    {
        if (!isset($this->collections[$id])) {
            $this->collections[$id] = new CollectionService($this->container, $id);
        }

        return $this->collections[$id];
    }

    /**
     * Получить ссылку на файл.
     *
     * @param int $id
     * @param string $filer
     * @return string
     *
     * @todo кеширование.
     */
    public function getFileUrl($id, $filer = null)
    {
        if (!is_numeric($id)) {
            return null;
        }

        /** @var File $file */
        $file = $this->em->getRepository('SmartMediaBundle:File')->find($id);

        if (empty($file)) {
            return null;
        }

        return $this->getCollection($file->getCollection()->getId())->get($id, $filer);
    }

    public function createCollection()
    {
        // @todo
    }

    public function removeCollection()
    {
        // @todo
    }
{'fraction_non_alphanumeric': 0.13677991137370754, 'fraction_numerical': 0.0, 'mean_word_length': 2.2651880424300868, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '1217245', 'n_tokens_mistral': 1004, 'n_tokens_neox': 991, 'n_words': 183}