for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Bobbyshaw\WatsonVisualRecognition;
/**
* Helper class
*
* This class defines static utility functions
*/
class Helper
{
* Initialize an object with a given array of parameters
* Parameters are automatically converted to camelCase. Any parameters which do
* not match a setter on the target object are ignored.
* @param Object $target The object to set parameters on
* @param array $parameters An array of parameters to set
public static function initialize($target, $parameters)
if (is_array($parameters)) {
foreach ($parameters as $key => $value) {
$method = 'set'.ucfirst(static::camelCase($key));
if (method_exists($target, $method)) {
$target->$method($value);
}
* Convert a string to camelCase. Strings already in camelCase will not be harmed.
* @param string $str The input string
* @return string camelCased output string
public static function camelCase($str)
return preg_replace_callback(
'/_([a-z])/',
function ($match) {
return strtoupper($match[1]);
},
$str
);