PHP code example of cloudcreativity / utils-value

1. Go to this page and download the library: Download cloudcreativity/utils-value 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/ */

    

cloudcreativity / utils-value example snippets

 php
public function setRole($value) {
  if (!in_array($value, ['lead', 'follow'])) {
    throw new \InvalidArgumentException('Expecting a valid dance role.');
  }

  // ...
}
 php
use CloudCreativity\Utils\Value\AbstractValue;

class DanceRole extends AbstractValue
{
  
  protected function accept($value): bool
  {
    return in_array($value, ['lead', 'follow'], true);
  }
}
 php
class DanceRole extends AbstractValue
{

  public function isLead(): bool
  {
    return $this->is('lead');
  }

  public function isFollow(): bool
  {
    return $this->is('follow');
  }

  // ... 
}