<commit_before><?php
/**
 * File SwaggerProvider.php
 *
 * @author <NAME> <<EMAIL>>
 */
namespace ERP\SwaggerBundle\Provider;

use ERP\Swagger\Entity\Swagger;
use ERP\Swagger\Factory\SwaggerFactory;
use Symfony\Component\HttpKernel\KernelInterface;

/**
 * Class SwaggerProvider
 *
 * @package ERP\SwaggerBundle
 * @subpackage Provider
 */
class SwaggerProvider
{

    /**
     * @var SwaggerFactory
     */
    protected $swaggerFactory;

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

    /**
     * Constructor
     *
     * @param KernelInterface $kernel
     * @param SwaggerFactory $swaggerFactory
     * @param $swaggerFile
     */
    public function __construct(KernelInterface $kernel, SwaggerFactory $swaggerFactory, $swaggerFile) {
        $swaggerFile = realpath($kernel->getRootDir() . '/' . $swaggerFile);

        $this->swaggerFactory = $swaggerFactory;
        $this->swaggerFile    = $swaggerFile;
    }

    /**
     * Parse & return the swagger doc
     *
     * @return Swagger
     */
    public function getSwagger()
    {
        return $this->swaggerFactory->build($this->swaggerFile);
    }
}<commit_msg>Added get Operation and Definition methods to swagger provider<commit_after><?php
/**
 * File SwaggerProvider.php
 *
 * @author <NAME> <<EMAIL>>
 */
namespace ERP\SwaggerBundle\Provider;

use ERP\Swagger\Entity\Operation;
use ERP\Swagger\Entity\Path;
use ERP\Swagger\Entity\Swagger;
use ERP\Swagger\Factory\SwaggerFactory;
use Symfony\Component\HttpKernel\KernelInterface;

/**
 * Class SwaggerProvider
 *
 * @package ERP\SwaggerBundle
 * @subpackage Provider
 */
class SwaggerProvider
{

    /**
     * @var SwaggerFactory
     */
    protected $swaggerFactory;

    /**
     * Swagger file path
     * @var string
     */
    protected $swaggerFile;

    /**
     * Parsed Swagger Doc
     * @var Swagger
     */
    protected $swagger;

    /**
     * Constructor
     *
     * @param KernelInterface $kernel
     * @param SwaggerFactory $swaggerFactory
     * @param string $swaggerFile
     */
    public function __construct(KernelInterface $kernel, SwaggerFactory $swaggerFactory, $swaggerFile) {
        $swaggerFile = realpath($kernel->getRootDir() . '/' . $swaggerFile);

        $this->swaggerFactory = $swaggerFactory;
        $this->swaggerFile    = $swaggerFile;
    }

    /**
     * Parse & return the swagger doc
     *
     * @return Swagger
     */
    public function getSwagger()
    {
        if (!$this->swagger) {
            $this->swagger = $this->swaggerFactory->build($this->swaggerFile);
        }

        return $this->swagger;
    }

    /**
     * Return the target swagger response schema
     *
     * @param string $path
     * @param string $operation
     * @param int $response
     * @return \ERP\Swagger\Entity\Schemas\SchemaInterface|null
     */
    public function getResponse($path, $operation = 'get', $response = 200)
    {
        $swagger = $this->getSwagger();
        /** @var Path $path */
        $path = $swagger->getPaths()->get($path);
        /** @var Operation $operation */
        $operation = $path->getOperations()->get($operation);

        return $operation->getResponses()->get($response);
    }

    /**
     * @param string $name
     * @return \ERP\Swagger\Entity\Schemas\SchemaInterface|null
     */
    public function getDefinition($name)
    {
        $swagger = $this->getSwagger();

        return $swagger->getDefinitions()->get($name);
    }
}
{'fraction_non_alphanumeric': 0.1335448514565907, 'fraction_numerical': 0.0008653014133256418, 'mean_word_length': 2.5789473684210527, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 34, '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': '1852466', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1047, 'n_words': 207}