Command line utility for agile project creation

v0.0.7 2020-04-16 21:13 UTC

This package is auto-updated.

Last update: 2024-03-17 06:56:50 UTC


README

logo.jpg

Build Status 68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f38303263333432343130303038636264386330382f6d61696e7461696e6162696c697479 68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f38303263333432343130303038636264386330382f746573745f636f766572616765

Lake is a command line utility that allows you to dynamically create classes and methods and create your reflexes for testing, also Lake can add methods to existing classes.

One of the most powerful features of Lake is that it automatically adds "USE" statements, Lake can recognize internal PHP classes, project classes and those that are present as Composer dependencies.

Install

PHP 7.1 or newer

composer require --dev millancore/lake

Configure

Lake takes to Composer the configuration of your project, he expects that the folder tests to store the reflections of test.

But not all projects have the same structure, if that's the case you can use the configuration file lake.yml and Config options.

Usage

In order for Lake to automatically add the USE statements from Composer's dependencies, you must run lake dump. If in the process of creation there is ambiguity in the name of the class or interface Lake will give you a choice from those available.

Only run once after installing some dependencies with Composer.

vendor/bin/lake dump

Create a class + method

vendor/bin/lake make src/DirName/ClassName MethodName 

If the name of the method is not defined, the defined arguments will be those of the constructor.

Options

Option Name Example Description
-e Extends -e Controller Define the class of the one that extends.
-a Arguments -a Int:id Method argument, you can use this option many times.
... ... -a Request If the name of the variable is not defined
Lake will create the variable name from the type.
... ... -a ?Array:params Nullable argument.
-r Return -r Response Defines the type of return.
-d DocBlock -d 'description' DocBlock Description of the method.

Examples

vendor/bin/lake make src/App/Command/CommandLake -e Command configure -a array:params

classFile: src/App/Command/CommandLake.php

<?php

namespace Lake\App\Command;

use Symfony\Component\Console\Command\Command;

class CommandLake extends Command
{

    /**
     * Undocumented function
     *
     * @param array $params
     * @return void
     */
    public function configure(array $params) : void
    {

    }


}

testFile: test/App/Command/CommandLakeTest.php

<?php

use PHPUnit\Framework\TestCase;
use Lake\App\Command\CommandLake;

class CommandLakeTest extends TestCase
{

    public function testDummyConfigureMethod()
    {

    }


}

Config options

Option Values Description
mode loose, strict By default the mode is loose, but a strict mode can be defined if you want to use TDD in the right way. The strict mode creates only the test files and in the code part create the files with a .lake extension.
src.dir src This is the folder where the code are, usually is src, but it can change.
src.namespace ... This is the base name defined in the composer's autoload.
test.dir tests This is the folder where the test are, usually is tests, but it can change.
test.extends ... The tests extend by default is PHPUnit\Framework\TestCase, but you can define another class.