<commit_before><?php
namespace Fabgg\JukeboxBundle\Lib;

use Doctrine\ORM\EntityManager;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\HttpFoundation\Session\Session;
use Fabgg\JukeboxBundle\Exception\JKException;
use Fabgg\JukeboxBundle\Model\JKFile;


class JukeboxIO
{
    protected $em;
    protected $session;

    protected $JKManager;

    public function __construct(EntityManager $entityManager, Session $session)
    {
        $this->em = $entityManager;
        $this->session = $session;
    }

    public function setManager(\Fabgg\JukeboxBundle\Lib\JukeboxManager $jukeboxManager){
        $this->JKManager= $jukeboxManager;
    }

    public function put(File $file, JKFile $JKFile){
        $JKFile->setFilePath($this->JKManager->getNewRandPath());
        $JKFile->setFileExtension($file->getExtension());
        $JKFile->setFileMine($file->getMimeType());
        $JKFile->setFileName($file->getFilename());
        $JKFile->setFileSize($file->getSize());
        $utils = new JukeboxUtils();
        $JKFile->setFileSlug($utils->slugify($file->getFilename()));
        $this->em->persist($JKFile);
        $this->em->flush();
        if($JKFile->getId()){
            $file->move(
                $this->JKManager->getAbsolutePath($JKFile), //Destination
                $JKFile->getFileName()
            );
            unset($file);
        } else {
            throw new JKException('Unable to save JKFile in db',104);
        }
        return $JKFile;
    }


    /**
     * @param JKFile $JKFile
     * @return $link
     */
    public function getLink(JKFile $JKFile){
        if($JKFile->getPublic()){
           $link =  'public/'.$JKFile->getId().'/';
        }
        else {<commit_msg>fix fileExtension<commit_after><?php
namespace Fabgg\JukeboxBundle\Lib;

use Doctrine\ORM\EntityManager;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\HttpFoundation\Session\Session;
use Fabgg\JukeboxBundle\Exception\JKException;
use Fabgg\JukeboxBundle\Model\JKFile;


class JukeboxIO
{
    protected $em;
    protected $session;

    protected $JKManager;

    public function __construct(EntityManager $entityManager, Session $session)
    {
        $this->em = $entityManager;
        $this->session = $session;
    }

    public function setManager(\Fabgg\JukeboxBundle\Lib\JukeboxManager $jukeboxManager){
        $this->JKManager= $jukeboxManager;
    }

    public function put(File $file, JKFile $JKFile){
        $JKFile->setFilePath($this->JKManager->getNewRandPath());
        $JKFile->setFileExtension($file->guessExtension());
        $JKFile->setFileMine($file->getMimeType());
        $JKFile->setFileName($file->getFilename());
        $JKFile->setFileSize($file->getSize());
        $utils = new JukeboxUtils();
        $JKFile->setFileSlug($utils->slugify($file->getFilename()));
        $this->em->persist($JKFile);
        $this->em->flush();
        if($JKFile->getId()){
            $file->move(
                $this->JKManager->getAbsolutePath($JKFile), //Destination
                $JKFile->getFileName()
            );
            unset($file);
        } else {
            throw new JKException('Unable to save JKFile in db',104);
        }
        return $JKFile;
    }


    /**
     * @param JKFile $JKFile
     * @return $link
     */
    public function getLink(JKFile $JKFile){
        if($JKFile->getPublic()){
           $link =  'public/'.$JKFile->getId().'/';
        }
        else {
{'fraction_non_alphanumeric': 0.14136125654450263, 'fraction_numerical': 0.0015706806282722514, 'mean_word_length': 2.883130081300813, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 59, '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': '759528', 'n_tokens_mistral': 1208, 'n_tokens_neox': 1137, 'n_words': 181}