PHP code example of danhanly / scientist-utility-matcher

1. Go to this page and download the library: Download danhanly/scientist-utility-matcher 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/ */

    

danhanly / scientist-utility-matcher example snippets


// initialise matcher
$matcher = new \DanHanly\Scientist\UtilityMatchers\ObjectPropertyMatcher;
// define property via string
$matcher->setProperties('propertyName');
// or via array
$matcher->setProperties(['propertyName', 'anotherPropertyName']);

// define property via string
$matcher = new \DanHanly\Scientist\UtilityMatchers\ObjectPropertyMatcher('propertyName');
// or via array
$matcher = new \DanHanly\Scientist\UtilityMatchers\ObjectPropertyMatcher(['propertyName', 'anotherPropertyName']);

// initialise matcher
$matcher = new \DanHanly\Scientist\UtilityMatchers\ArrayKeyMatcher;
// define keys via string
$matcher->setKeys('keyName');
// or via array
$matcher->setKeys(['keyName', 'anotherKeyName']);

// define key via string
$matcher = new \DanHanly\Scientist\UtilityMatchers\ArrayKeyMatcher('keyName');
// or via array
$matcher = new \DanHanly\Scientist\UtilityMatchers\ArrayKeyMatcher(['keyName', 'anotherKeyName']);

// define key via string
$matcher = new \DanHanly\Scientist\UtilityMatchers\ArrayKeyMatcher('data->user->address->zip');

// intialise with a 0 minimum
$matcher = new \DanHanly\Scientist\UtilityMatchers\MinMaxMatcher(0);
// intialise with a 10 maximum
$matcher = new \DanHanly\Scientist\UtilityMatchers\MinMaxMatcher(null, 10);
// intialise between 0 and 10
$matcher = new \DanHanly\Scientist\UtilityMatchers\MinMaxMatcher(0, 10);

$experiment = (new Scientist\Laboratory)
  ->experiment('experiment title')
  ->control($controlCallback)
  ->trial('trial name', $trialCallback)
  ->matcher($matcher);