<commit_before><?php
/**
 * @filesource
 * @copyright (c) 2013 - 2017 Cross Solution (http://cross-solution.de)
 * @license MIT
 * @author <NAME> <<EMAIL>>
 * @since 0.30
 */
namespace SimpleImport\Hydrator;

use Zend\Hydrator\HydrationInterface;
use Jobs\Entity\AtsMode;
use SimpleImport\Job\GeocodeLocation;
use Doctrine\Common\Collections\ArrayCollection;

class JobHydrator implements HydrationInterface
{
    
    /**
     * @var GeocodeLocation
     */
    private $geocodeLocation;
    
    /**
     * @param GeocodeLocation $geocodeLocation
     */
    public function __construct(GeocodeLocation $geocodeLocation)
    {
        $this->geocodeLocation = $geocodeLocation;
    }
    
    /**
     * {@inheritDoc}
     * @see \Zend\Hydrator\HydrationInterface::hydrate()
     */
    public function hydrate(array $data, $job)
    {
        /** @var \Jobs\Entity\Job $job */
        $job->setTitle($data['title'])
            ->setLocation($data['location'])
            ->setCompany($data['company'])
            ->setReference($data['reference'])
            ->setContactEmail($data['contactEmail'])
            ->setLanguage($data['language'])
            ->setLink($data['link'])
            ->setDatePublishStart($data['datePublishStart'])
            ->setLogoRef($data['logoRef']);
        
        if ($data['datePublishEnd']) {
            $job->setDatePublishEnd($data['datePublishEnd']);
        }

        if ($data['linkApply']) {
            $job->setAtsMode(new AtsMode(AtsMode::MODE_URI, $data['linkApply']));
        } else {
            $job->setAtsMode(new AtsMode(AtsMode::MODE_NONE));
        }
        
        $locations = $this->geocodeLocation->getLocations($data['location']);
        
        if ($locations) {
            $locationCollection = $job->getLocations();
            $locationCollection->clear();
            
            foreach ($locations as $location) {
               $locationCollection->add($location);
            }
        }
            
        // TODO: implement classifications
    }
}<commit_msg>Always set locations (even if no geo locations are found) #8<commit_after><?php
/**
 * @filesource
 * @copyright (c) 2013 - 2017 Cross Solution (http://cross-solution.de)
 * @license MIT
 * @author <NAME> <<EMAIL>>
 * @since 0.30
 */
namespace SimpleImport\Hydrator;

use Zend\Hydrator\HydrationInterface;
use Jobs\Entity\AtsMode;
use SimpleImport\Job\GeocodeLocation;
use Doctrine\Common\Collections\ArrayCollection;

class JobHydrator implements HydrationInterface
{
    
    /**
     * @var GeocodeLocation
     */
    private $geocodeLocation;
    
    /**
     * @param GeocodeLocation $geocodeLocation
     */
    public function __construct(GeocodeLocation $geocodeLocation)
    {
        $this->geocodeLocation = $geocodeLocation;
    }
    
    /**
     * {@inheritDoc}
     * @see \Zend\Hydrator\HydrationInterface::hydrate()
     */
    public function hydrate(array $data, $job)
    {
        /** @var \Jobs\Entity\Job $job */
        $job->setTitle($data['title'])
            ->setLocation($data['location'])
            ->setCompany($data['company'])
            ->setReference($data['reference'])
            ->setContactEmail($data['contactEmail'])
            ->setLanguage($data['language'])
            ->setLink($data['link'])
            ->setDatePublishStart($data['datePublishStart'])
            ->setLogoRef($data['logoRef']);
        
        if ($data['datePublishEnd']) {
            $job->setDatePublishEnd($data['datePublishEnd']);
        }

        if ($data['linkApply']) {
            $job->setAtsMode(new AtsMode(AtsMode::MODE_URI, $data['linkApply']));
        } else {
            $job->setAtsMode(new AtsMode(AtsMode::MODE_NONE));
        }
        
        $locations = $this->geocodeLocation->getLocations($data['location']);
        $job->setLocations(new ArrayCollection($locations));
            
        // TODO: implement classifications
    }
}
{'fraction_non_alphanumeric': 0.15060851926977686, 'fraction_numerical': 0.0058316430020283975, 'mean_word_length': 2.433420365535248, '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': '2618333', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1155, 'n_words': 180}