<commit_before><?php

namespace CanalTP\MttBridgeBundle\Perimeter;

use FOS\UserBundle\Model\UserInterface;
use CanalTP\MttBundle\Services\PerimeterManager;
use CanalTP\SamEcoreApplicationManagerBundle\Perimeter\AbstractBusinessPerimeterManager;
use CanalTP\SamEcoreApplicationManagerBundle\Perimeter\BusinessPerimeterInterface;
use CanalTP\SamEcoreApplicationManagerBundle\Perimeter\BusinessPerimeter;

class BusinessPerimeterManager extends AbstractBusinessPerimeterManager
{
    private $perimeters;

    public function __construct(PerimeterManager $perimeterManager)
    {
        $this->perimeterManager = $perimeterManager;
    }

    /**
     * Add a user to a perimeter
     *
     * @param UserInterface              $user
     * @param BusinessPerimeterInterface $perimeter
     */
    public function addUserToPerimeter(UserInterface $user, BusinessPerimeterInterface $perimeter)
    {
        $this->perimeterManager->addUserToPerimeter($user->getId(), $perimeter->getId());
    }

    /**
     * Get the perimeters
     *
     * @return BusinessPerimeterInterface[] The perimeters
     * @DeadCode, it seems
     */
    public function getPerimeters()
    {
        if (null === $this->perimeters) {
            $perimeters = array();
            foreach ($this->perimeterManager->findAll() as $network) {
                $perimeter = new BusinessPerimeter($network->getExternalPerimeterId());
                $perimeter->setId($network->getId());
                $this->perimeters[] = $perimeter;
            }
        }

        return $this->perimeters;
    }

    /**
     * Delete a user from a perimeter
     *
     * @param UserInterface $user
     */
    public function deleteUserPerimeters(UserInterface $user)
    {
        $this->perimeterManager->deleteUserPerimeters($user);
    }

    /**
     * Get a user's perimeters
     *
     * @param UserInterface $user
     *
     * @return BusinessPerimeterInterface[] The perimeters
     */
    public function getUserPerimeters(UserInterface $user)
    {
        $userPerimeters = array();
        foreach ($this->perimeterManager->findUserPerimeters($user) as $network) {
            foreach ($this->getPerimeters() as $perimeter) {
                if ($perimeter->getId() == $network['id'] && $perimeter->getName() == $network['external_id']) {
                    $userPerimeters[] = $perimeter;
                    break 1;
                }
            }
        }<commit_msg>fix call in a a non existing method<commit_after><?php

namespace CanalTP\MttBridgeBundle\Perimeter;

use FOS\UserBundle\Model\UserInterface;
use CanalTP\MttBundle\Services\PerimeterManager;
use CanalTP\SamEcoreApplicationManagerBundle\Perimeter\AbstractBusinessPerimeterManager;
use CanalTP\SamEcoreApplicationManagerBundle\Perimeter\BusinessPerimeterInterface;
use CanalTP\SamEcoreApplicationManagerBundle\Perimeter\BusinessPerimeter;

class BusinessPerimeterManager extends AbstractBusinessPerimeterManager
{
    private $perimeters;

    public function __construct(PerimeterManager $perimeterManager)
    {
        $this->perimeterManager = $perimeterManager;
    }

    /**
     * Add a user to a perimeter
     *
     * @param UserInterface              $user
     * @param BusinessPerimeterInterface $perimeter
     */
    public function addUserToPerimeter(UserInterface $user, BusinessPerimeterInterface $perimeter)
    {
        $this->perimeterManager->addUserToPerimeter($user->getId(), $perimeter->getId());
    }

    /**
     * Get the perimeters
     *
     * @return BusinessPerimeterInterface[] The perimeters
     * @DeadCode, it seems
     */
    public function getPerimeters()
    {
        if (null === $this->perimeters) {
            $perimeters = array();
            foreach ($this->perimeterManager->findAll() as $network) {
                $perimeter = new BusinessPerimeter($network->getExternalPerimeterId());
                $perimeter->setId($network->getId());
                $this->perimeters[] = $perimeter;
            }
        }

        return $this->perimeters;
    }

    /**
     * Delete a user from a perimeter
     *
     * @param UserInterface $user
     */
    public function deleteUserPerimeters(UserInterface $user)
    {
        // @todo Implement the functionality
    }

    /**
     * Get a user's perimeters
     *
     * @param UserInterface $user
     *
     * @return BusinessPerimeterInterface[] The perimeters
     */
    public function getUserPerimeters(UserInterface $user)
    {
        $userPerimeters = array();
        foreach ($this->perimeterManager->findUserPerimeters($user) as $network) {
            foreach ($this->getPerimeters() as $perimeter) {
                if ($perimeter->getId() == $network['id'] && $perimeter->getName() == $network['external_id']) {
                    $userPerimeters[] = $perimeter;
                    break 1;
                }
            }
        }
{'fraction_non_alphanumeric': 0.10783316378433368, 'fraction_numerical': 0.0004069175991861648, 'mean_word_length': 2.6307237813884785, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, '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': '4653799', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1292, 'n_words': 256}