PHP code example of pinekta / geta-setta

1. Go to this page and download the library: Download pinekta/geta-setta 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/ */

    

pinekta / geta-setta example snippets




namespace Foo\bar;

use Pinekta\GetaSetta\AccessorAvailable;

class AudioPlayer
{
    use AccessorAvailable;
    private $disc;
    private $tune;
}

$audioPlayer = new AudioPlayer();
$audioPlayer->setDisc('Editors [The Back Room]')
            ->setTune('Bullets');
echo $audioPlayer->getDisc();            // "Editors [The Back Room]" outputs
echo $audioPlayer->getTune();            // "Bullets" outputs

$audioPlayer->disc('Can [Monster Movie]');
            ->tune('You Doo Right');
echo $audioPlayer->disc();               // "Can [Monster Movie]" outputs
echo $audioPlayer->tune();               // "You Doo Right" outputs

class AudioPlayer
{
    use AccessorAvailable;
    private $disc;
    private $tune;
}

$audioPlayer = new AudioPlayer();
// Case array
$audioPlayer->fill([
    'disc' => 'Number Girl [SAPPUKEI]',
    'tune' => 'ZEGEN VS UNDERCOVER',
]);

// Case object
$set = new \stdClass();
$set->disc = 'Joy Division [Unknown Pleasures]';
$set->tune = 'New Dawn Fades';
$audioPlayer->fill($set);

class Disc
{
    use AccessorAvailable;
    protected static $gsUnwritableProps = ['id'];
    private $id;
    private $name;
    private $size;
}

$disc = new Disc();
$disc->setId(100);                // BadMethodCallException occurs

class AudioPlayer
{
    use AccessorAvailable;
    protected static $gsInaccessibleProps = ['tune'];
    private $disc;
    private $tune;
}

$audioPlayer = new AudioPlayer();
$audioPlayer->setDisc('Captain Beefheart [Trout Mask Replica]');
echo $audioPlayer->getDisc();            // "Captain Beefheart [Trout Mask Replica]" outputs

$audioPlayer->setTune('Ella Guru');      // BadMethodCallException occurs
$audioPlayer->getTune();                 // BadMethodCallException occurs
$audioPlayer->tune('Well');              // BadMethodCallException occurs
$audioPlayer->tune();                    // BadMethodCallException occurs