<commit_before><?php

namespace jfadich\EloquentResources\Console;

use Illuminate\Filesystem\Filesystem;
use Symfony\Component\Console\Input\InputOption;

/**
 * Command to generate a new presenter class
 */
class MakeTransformableCommand extends GeneratorCommand
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $name = 'make:transformable';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Create a new Transformable Model class';

    /**
     * The type of class being generated
     *
     * @var string
     */
    protected $type = 'Model';

    /**
     * Set the base class then call the parent
     *
     * @param Filesystem $files
     */
    public function __construct(Filesystem $files)
    {
        $this->parentClass = config('transformers.classes.model');

        parent::__construct($files);
    }

    /**
     * Execute the console command. Generate a transformer if the -api switch is on
     *
     * @return void
     */
    public function fire()
    {
        if ($this->option('present')) {
            $this->addTrait(\jfadich\EloquentResources\Traits\Presentable::class);
        }

        if (parent::fire() !== false) {
            $this->call('make:transformer', ['name' => $this->argument('name') . 'Transformer', '-m' => $this->parseName($this->argument('name'))]);

            if ($this->option('present')) {
                $this->call('make:presenter', ['name' => $this->argument('name') . 'Presenter']);
            }
        }<commit_msg>fix make:transformable to support both Laravel 5.1 and 5.4<commit_after><?php

namespace jfadich\EloquentResources\Console;

use Illuminate\Filesystem\Filesystem;
use Symfony\Component\Console\Input\InputOption;

/**
 * Command to generate a new presenter class
 */
class MakeTransformableCommand extends GeneratorCommand
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $name = 'make:transformable';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Create a new Transformable Model class';

    /**
     * The type of class being generated
     *
     * @var string
     */
    protected $type = 'Model';

    /**
     * Set the base class then call the parent
     *
     * @param Filesystem $files
     */
    public function __construct(Filesystem $files)
    {
        $this->parentClass = config('transformers.classes.model');

        parent::__construct($files);
    }

    /**
     * Execute the console command. Generate a transformer if the -api switch is on
     *
     * @return void
     */
    public function fire()
    {
        if ($this->option('present')) {
            $this->addTrait(\jfadich\EloquentResources\Traits\Presentable::class);
        }

        if (parent::fire() !== false) {
            $name = $this->argument('name');

            // parseName() was renamed to qualifyClass() in 5.4. Check which method to use to support 5.1-5.4
            $model = method_exists($this, 'parseName') ? $this->parseName($name) : $this->qualifyClass($name);
            $this->call('make:transformer', ['name' => $name . 'Transformer', '-m' => $model]);

            if ($this->option('present')) {
                $this->call('make:presenter', ['name' => $model . 'Presenter']);
            }
        }
{'fraction_non_alphanumeric': 0.1393063583815029, 'fraction_numerical': 0.002890173410404624, 'mean_word_length': 2.350435624394966, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, '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': '2259609', 'n_tokens_mistral': 993, 'n_tokens_neox': 972, 'n_words': 250}