PHP code example of metarush / getter

1. Go to this page and download the library: Download metarush/getter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

metarush / getter example snippets


(new \MetaRush\Getter\Generator)
    ->setAdapter('yaml')
    ->setClassName('MyNewClass')
    ->setSourceFile('foo/sample.yaml')
    ->setLocation('foo/')
    ->generate();



declare(strict_types=1);

namespace MyNamespace;

class MyNewClass
{
    private $stringVar = 'foo';
    private $intVar = 9;
    private $floatVar = 2.1;
    private $boolVar = true;
    private $arrayVar = [0 => 'foo', 1 => 1.3];

    public function getStringVar(): string
    {
        return $this->stringVar;
    }

    public function getIntVar(): int
    {
        return $this->intVar;
    }

    public function getFloatVar(): float
    {
        return $this->floatVar;
    }

    public function getBoolVar(): bool
    {
        return $this->boolVar;
    }

    public function getArrayVar(): array
    {
        return $this->arrayVar;
    }
}

[
    'x', // string
    1, // int
    1.2, // float
    true, // true
    [0 => 'x'] // array
];


// $replacementValues should contain key value pair that matches the dummified data

$newClass = new MyNewClass($replacementValues);