Formats case of the input array or scalar to desired case

@param array|string $input
@param int|null $levels How many levels of an array keys to transform - by default recurse infiniately (null)
@return array $transformed
556143
protected function formatKeyCase($input, $levels = null)
    {
        $caseFormat = APIBoilerplate::getResponseCaseType();

        if ($caseFormat == APIBoilerplate::CAMEL_CASE) {
            if (is_array($input)) {
                $transformed = camel_case_array_keys($input, $levels);
            } else {
                $transformed = camel_case($input);
            }
        } elseif ($caseFormat == APIBoilerplate::SNAKE_CASE) {
            if (is_array($input)) {
                $transformed = snake_case_array_keys($input, $levels);
            } else {
                $transformed = snake_case($input);
            }
        }

        return $transformed;
    }
2467
protected function recursivelyRemoveEmptyReplacements(array $input)
    {
        foreach ($input as &$value) {
            if (is_array($value)) {
                $value = $this->recursivelyRemoveEmptyReplacements($value);
            }
        }

        return array_filter($input, function ($value) {
            if (is_string($value)) {
                return ! starts_with($value, ':');
            }

            return true;
        });
    }
1059624
private function fromCamelCase($input) {
	       
	        $a = preg_split(
		        '/(^[^A-Z]+|[A-Z][^A-Z]+)/',
		        $input,
		        -1, /* no limit for replacement count */
		        PREG_SPLIT_NO_EMPTY /*don't return empty elements*/
		            | PREG_SPLIT_DELIM_CAPTURE /*don't strip anything from output array*/
		    );
	        return strtolower(join($a, "-"));
	}
827183
public function renderNested(array $items, $level = 0)
    {
        $out = '';
        foreach ($items as $item) {
            $out .= $this->_renderItem($item, $level);
        }
        return $out;
    }
68586
public function keyToValue(array $input)
    {
        $output = array();

        foreach ($input as $key => $value) {
            $output[] = array($key, $value);
        }

        return $output;
    }
1302873
public static function cast( $input, ?array $default = null, bool $deep = false ): ?array {
    if( !static::is( $input, true ) ) return $default;
    else {

      // handle simple cases to speed up the process
      if( !$deep ) {
        if( is_array( $input ) ) return $input;
        else if( $input instanceof \StdClass ) return (array) $input;
        else if( $input instanceof StorageInterface ) return $input->getArray( '' );
      }

      $tmp = [];
      foreach( $input as $k => $t ) {
        $tmp[ $k ] = $deep && static::is( $t, true ) ? static::cast( $t, null, $deep ) : $t;
      }

      return $tmp;
    }
  }
887262
public static function normalize(&$input)
    {
        //==============================================================================
        //      Convert ArrayObjects To Simple Array
        if ($input instanceof ArrayObject) {
            $input = $input->getArrayCopy();
            //==============================================================================
            // Normalize Contents
            self::normalize($input);

        //==============================================================================
        // Normalize Array Contents
        } elseif (is_array($input)) {
            foreach ($input as &$value) {
                self::normalize($value);
            }

            //==============================================================================
        // Normalize Bool as Strings
        } elseif (is_bool($input)) {
            $input = $input ? '1' : '0';

        //==============================================================================
        // Normalize Numbers as Strings
        } elseif (is_numeric($input)) {
            $input = strval($input);
        }

        return $input;
    }
166144
public function indent($level = null)
    {
        $level = $level ?: $this->getLevel();
        array_push($this->indentStack, $level);

        return $level;
    }
130984
public function genSalt($input = null)
    {
        if (!$input) {
            $input = $this->_getRandomBytes(3);
        }

        // Hash identifier
        $identifier = '_';

        // Cost factor - must be between 1 and 16777215
        $costFactor = min(max($this->_iterationCount, 1), 0xffffff);
        // Should be odd to avoid revealing weak DES keys
        if (($costFactor % 2) == 0) {
            --$costFactor;
        }

        // Salt string
        $salt = $this->_encode64($input, 3);

        // _CCCCSSSS
        return $identifier . $this->_encodeInt24($costFactor) . $salt;
    }
839498
public static function recursive(array $array, int $level = 1): string
    {
        if ($level === 1) {
            self::$value = '';
        }

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                self::$value .= str_repeat('-', $level - 1) .
                    (($level - 1 > 0) ? ' ' : '') .
                    $key . ':' . PHP_EOL;
                self::recursive($value, $level + 1);
            } else {
                self::$value .= str_repeat('-', $level - 1) .
                    (($level - 1 > 0) ? ' ' : '') .
                    $key . ':' . $value . PHP_EOL;
            }
        }

        return self::$value;
    }
372678
private function getFilters(array $filters, $level)
    {
        if (empty($filters)) {
            return '';
        }

        $name     = array_shift($filters);
        $method   = $this->getFindMethod($name);
        $filter   = ($method !== 'last') ? var_export($name, true) : '';
        $callable = $this->getCallable('$filter');
        $msg      = var_export($name, true);

        return sprintf($this->prepare(self::FILTER, $level), $method, $filter, $callable, $msg, $this->getFilters($filters, $level));
    }
1234910
protected function _flatten($input) {
    // produce a map of all subjects and name each bnode
    $namer = new UniqueNamer('_:b');
    $graphs = (object)array('@default' => new stdClass());
    $this->_createNodeMap($input, $graphs, '@default', $namer);

    // add all non-default graphs to default graph
    $default_graph = $graphs->{'@default'};
    $graph_names = array_keys((array)$graphs);
    foreach($graph_names as $graph_name) {
      if($graph_name === '@default') {
        continue;
      }
      $node_map = $graphs->{$graph_name};
      if(!property_exists($default_graph, $graph_name)) {
        $default_graph->{$graph_name} = (object)array(
          '@id' => $graph_name, '@graph' => array());
      }
      $subject = $default_graph->{$graph_name};
      if(!property_exists($subject, '@graph')) {
        $subject->{'@graph'} = array();
      }
      $ids = array_keys((array)$node_map);
      sort($ids);
      foreach($ids as $id) {
        $node = $node_map->{$id};
        // only add full subjects
        if(!self::_isSubjectReference($node)) {
          $subject->{'@graph'}[] = $node;
        }
      }
    }

    // produce flattened output
    $flattened = array();
    $keys = array_keys((array)$default_graph);
    sort($keys);
    foreach($keys as $key) {
      $node = $default_graph->{$key};
      // only add full subjects to top-level
      if(!self::_isSubjectReference($node)) {
        $flattened[] = $node;
      }
    }
    return $flattened;
  }
751695
static function encode_jsfunc($input=array(), $funcs=array(), $level=0)
	{
		foreach($input as $key=>$value)
		{
			if(is_array($value))
			{
				$ret = self::encode_jsfunc($value, $funcs, 1);
				$input[$key]=$ret[0];
				$funcs=$ret[1];
			}
			else
			{
				if(preg_match('/^\s*function\s*\(/', $value))
				{
					$func_key="#".uniqid()."#";
					$funcs[$func_key]=$value;
					$input[$key]=$func_key;
				}
			}
		}

		if($level==1)
			return array($input, $funcs);

		$input_json = str_replace('\/', '/', json_encode($input));
		foreach($funcs as $key => $value)
				$input_json = str_replace('"'.$key.'"', $value, $input_json);

		return $input_json;
	}
1215454
protected static function convertBase(
        /*# string */ $input,
        /*# string */ $fromBase,
        /*# string */ $toBase
    )/*# : string */ {
        if ($fromBase === $toBase) {
            return $input;
        } elseif ($fromBase === self::BASE10) {
            return static::fromBase10($input, $toBase);
        } elseif ($toBase === self::BASE10) {
            return static::toBase10($input, $fromBase);
        } else {
            return static::fromBase10(static::toBase10($input, $fromBase), $toBase);
        }
    }
609867
protected function generateArrayLines(array $values, $level = 1, $indentation = '    ')
    {
        $index = 0;
        $lines = [];
        $count = count($values);

        foreach ($values as $key => $value) {
            $index  = $index + 1;
            $comma  = ($index < $count) ? ',' : '';

            $lines[] = "'$key' => " . $value . $comma;
        }

        if ($level === 0) {
            return $lines;
        }

        return $this->addIndentation($lines, $level, $indentation);
    }
269744
private function purgeObjects(array $data, $level) {
        $tmp = [];
        foreach ($data as $k => $v) {
            if (is_array($v)) {
                $tmp[$k] = ($this->deepLevel !== null && $level <= $this->deepLevel) || $this->deepLevel === null
                    ? $this->purgeObjects($v, ++$level)
                    : '(array)';

            } elseif (is_object($v)) {
                $tmp[$k] = spl_object_hash($v) . ' ' . get_class($v);
            } else {
                ob_start();
                var_dump($v);
                $tmp[$k] = str_replace('</pre>', '',
                    preg_replace("/<pre[^>]+\>/i", '$1', ob_get_clean()));
            }
        }
        return $tmp;
    }
1297673
private function inputs(array $inputs)
    {
        if ($inputs) {
            foreach ($inputs as $input) {
                yield $input;
            }

            return;
        }

        foreach ($this->volumeManager->all() as $volume) {
            $iterator = new RecursiveIteratorIterator($volume->getIterator(), RecursiveIteratorIterator::SELF_FIRST);
            foreach ($iterator as $folder) {
                foreach ($volume->findFilesByFolder($folder) as $file) {
                    $input = InputDescriptor::fromFile($file);
                    yield $input;
                }
            }
        }
    }