protected function _funcCaseToProperties(
        $funcCase)
    {
        // This algorithm is the exact inverse of PropertyTranslation.
        // Read that class for more information.

        // There's nothing to do if the input is empty...
        if (!strlen($funcCase)) {
            return false;
        }

        // First, we must decode our encoded representation of any special PHP
        // operators, just in case their property name had illegal chars.
        $funcCase = SpecialOperators::decodeOperators($funcCase);

        // Now remove and count all leading underscores (important!).
        // Example: "__MessageList" => "MessageList".
        $result = ltrim($funcCase, '_');
        $leadingUnderscores = strlen($funcCase) - strlen($result);

        // Verify that the REMAINING input result doesn't contain lowercase a-z
        // as its FIRST character. In that case, we were given invalid input,
        // because the FuncCase style REQUIRES that the first character is a
        // NON-LOWERCASE. Anything else is fine, such as UpperCase, numbers or
        // special characters, etc, but never lowercase, since our splitter
        // splitFunctionName() would NEVER give us a FuncName part with a
        // leading lowercase letter! However, the splitter COULD give us
        // something like "__m" from "get__m". But our PropertyTranslation would
        // NEVER create output like "__m". It would have created "__M". So
        // anything that now remains at the start of the string after stripping
        // leading underscores MUST be non-lowercase.
        if (preg_match('/^[a-z]/', $result)) {
            return false;
        }

        // Split the input into chunks on all camelcase boundaries.
        // NOTE: Since all chunks are split on camelcase boundaries below, it
        // means that each chunk ONLY holds a SINGLE fragment which can ONLY
        // contain at most a SINGLE capital letter (the chunk's first letter).
        // NOTE: The "PREG_SPLIT_NO_EMPTY" ensures that we don't get an empty
        // leading array entry when the input begins with an "Upper" character.
        // NOTE: If this doesn't match anything (meaning there are no uppercase
        // characters to split on), the input is returned as-is. Such as "123".
        // NOTE: If $result is an empty string, this returns an empty array.
        // Example: "MessageList" => "Message" & "List"
        $chunks = preg_split('/(?=[A-Z])/', $result, -1, PREG_SPLIT_NO_EMPTY);
        if ($chunks === false) {
            return false; // Only happens on regex engine failure, NOT mismatch!
        }
        $chunkCount = count($chunks);

        // Handle the scenario where there are no chunks ($result was empty).
        // NOTE: Thanks to all of the validation above, this can ONLY happen
        // when input consisted entirely of underscores with nothing after that.
        if ($chunkCount === 0) {
            // Insert a fake, empty element to act as the first chunk, to ensure
            // that we have something to insert the underscores into.
            $chunks[] = '';
            $chunkCount++;
        }

        // Lowercase the leading uppercase of 1st chunk (whatever is in there),
        // since that chunk needs lowercase in both snake_case and camelCase.
        // Example: "Message" & "List" => "message" & "List"
        $chunks[0] = lcfirst($chunks[0]);

        // If there were any leading underscores, prepend all of them to the 1st
        // chunk, which ensures that they become part of the first chunk.
        // Example: "__message" & "List"
        if ($leadingUnderscores > 0) {
            $chunks[0] = str_repeat('_', $leadingUnderscores).$chunks[0];
        }

        // Now let's create the snake_case and camelCase variable names.

        // The property name chunks are already in perfect format for camelCase.
        // The first chunk starts with a lowercase letter, and all other chunks
        // start with an uppercase letter. So generate the camelCase property
        // name version first. But only if there are 2+ chunks. Otherwise NULL.
        // NOTE: Turns "i,Tunes,Item" into "iTunesItem", and "foo" into NULL.
        $camelPropName = $chunkCount >= 2 ? implode('', $chunks) : null;

        // Now make the second property name chunk and onwards into lowercase,
        // and then generate the all-lowercase "snake_case" property name.
        // NOTE: Turns "some,Property,Name" into "some_property_name".
        for ($i = 1; $i < $chunkCount; ++$i) {
            $chunks[$i] = lcfirst($chunks[$i]); // Only first letter can be UC.
        }
        $snakePropName = implode('_', $chunks);

        // Return the final snake_case and camelCase property names.
        return [
            'snake' => $snakePropName,
            'camel' => $camelPropName,
        ];
    }
protected function _funcCaseToProperties(
        $funcCase)
    {
        // This algorithm is the exact inverse of PropertyTranslation.
        // Read that class for more information.

        // There's nothing to do if the input is empty...
        if (!strlen($funcCase)) {
            return false;
        }

        // First, we must decode our encoded representation of any special PHP
        // operators, just in case their property name had illegal chars.
        $funcCase = SpecialOperators::decodeOperators($funcCase);

        // Now remove and count all leading underscores (important!).
        // Example: "__MessageList" => "MessageList".
        $result = ltrim($funcCase, '_');
        $leadingUnderscores = strlen($funcCase) - strlen($result);

        // Verify that the REMAINING input result doesn't contain lowercase a-z
        // as its FIRST character. In that case, we were given invalid input,
        // because the FuncCase style REQUIRES that the first character is a
        // NON-LOWERCASE. Anything else is fine, such as UpperCase, numbers or
        // special characters, etc, but never lowercase, since our splitter
        // splitFunctionName() would NEVER give us a FuncName part with a
        // leading lowercase letter! However, the splitter COULD give us
        // something like "__m" from "get__m". But our PropertyTranslation would
        // NEVER create output like "__m". It would have created "__M". So
        // anything that now remains at the start of the string after stripping
        // leading underscores MUST be non-lowercase.
        if (preg_match('/^[a-z]/', $result)) {
            return false;
        }

        // Split the input into chunks on all camelcase boundaries.
        // NOTE: Since all chunks are split on camelcase boundaries below, it
        // means that each chunk ONLY holds a SINGLE fragment which can ONLY
        // contain at most a SINGLE capital letter (the chunk's first letter).
        // NOTE: The "PREG_SPLIT_NO_EMPTY" ensures that we don't get an empty
        // leading array entry when the input begins with an "Upper" character.
        // NOTE: If this doesn't match anything (meaning there are no uppercase
        // characters to split on), the input is returned as-is. Such as "123".
        // NOTE: If $result is an empty string, this returns an empty array.
        // Example: "MessageList" => "Message" & "List"
        $chunks = preg_split('/(?=[A-Z])/', $result, -1, PREG_SPLIT_NO_EMPTY);
        if ($chunks === false) {
            return false; // Only happens on regex engine failure, NOT mismatch!
        }
        $chunkCount = count($chunks);

        // Handle the scenario where there are no chunks ($result was empty).
        // NOTE: Thanks to all of the validation above, this can ONLY happen
        // when input consisted entirely of underscores with nothing after that.
        if ($chunkCount === 0) {
            // Insert a fake, empty element to act as the first chunk, to ensure
            // that we have something to insert the underscores into.
            $chunks[] = '';
            $chunkCount++;
        }

        // Lowercase the leading uppercase of 1st chunk (whatever is in there),
        // since that chunk needs lowercase in both snake_case and camelCase.
        // Example: "Message" & "List" => "message" & "List"
        $chunks[0] = lcfirst($chunks[0]);

        // If there were any leading underscores, prepend all of them to the 1st
        // chunk, which ensures that they become part of the first chunk.
        // Example: "__message" & "List"
        if ($leadingUnderscores > 0) {
            $chunks[0] = str_repeat('_', $leadingUnderscores).$chunks[0];
        }

        // Now let's create the snake_case and camelCase variable names.

        // The property name chunks are already in perfect format for camelCase.
        // The first chunk starts with a lowercase letter, and all other chunks
        // start with an uppercase letter. So generate the camelCase property
        // name version first. But only if there are 2+ chunks. Otherwise NULL.
        // NOTE: Turns "i,Tunes,Item" into "iTunesItem", and "foo" into NULL.
        $camelPropName = $chunkCount >= 2 ? implode('', $chunks) : null;

        // Now make the second property name chunk and onwards into lowercase,
        // and then generate the all-lowercase "snake_case" property name.
        // NOTE: Turns "some,Property,Name" into "some_property_name".
        for ($i = 1; $i < $chunkCount; ++$i) {
            $chunks[$i] = lcfirst($chunks[$i]); // Only first letter can be UC.
        }
        $snakePropName = implode('_', $chunks);

        // Return the final snake_case and camelCase property names.
        return [
            'snake' => $snakePropName,
            'camel' => $camelPropName,
        ];
    }
protected function _funcCaseToProperties ( $ funcCase ) { // This algorithm is the exact inverse of PropertyTranslation. // Read that class for more information. // There's nothing to do if the input is empty... if ( ! strlen ( $ funcCase ) ) { return false ; } // First, we must decode our encoded representation of any special PHP // operators, just in case their property name had illegal chars. $ funcCase = SpecialOperators :: decodeOperators ( $ funcCase ) ; // Now remove and count all leading underscores (important!). // Example: "__MessageList" => "MessageList". $ result = ltrim ( $ funcCase , '_' ) ; $ leadingUnderscores = strlen ( $ funcCase ) - strlen ( $ result ) ; // Verify that the REMAINING input result doesn't contain lowercase a-z // as its FIRST character. In that case, we were given invalid input, // because the FuncCase style REQUIRES that the first character is a // NON-LOWERCASE. Anything else is fine, such as UpperCase, numbers or // special characters, etc, but never lowercase, since our splitter // splitFunctionName() would NEVER give us a FuncName part with a // leading lowercase letter! However, the splitter COULD give us // something like "__m" from "get__m". But our PropertyTranslation would // NEVER create output like "__m". It would have created "__M". So // anything that now remains at the start of the string after stripping // leading underscores MUST be non-lowercase. if ( preg_match ( '/^[a-z]/' , $ result ) ) { return false ; } // Split the input into chunks on all camelcase boundaries. // NOTE: Since all chunks are split on camelcase boundaries below, it // means that each chunk ONLY holds a SINGLE fragment which can ONLY // contain at most a SINGLE capital letter (the chunk's first letter). // NOTE: The "PREG_SPLIT_NO_EMPTY" ensures that we don't get an empty // leading array entry when the input begins with an "Upper" character. // NOTE: If this doesn't match anything (meaning there are no uppercase // characters to split on), the input is returned as-is. Such as "123". // NOTE: If $result is an empty string, this returns an empty array. // Example: "MessageList" => "Message" & "List" $ chunks = preg_split ( '/(?=[A-Z])/' , $ result , - 1 , PREG_SPLIT_NO_EMPTY ) ; if ( $ chunks === false ) { return false ; // Only happens on regex engine failure, NOT mismatch! } $ chunkCount = count ( $ chunks ) ; // Handle the scenario where there are no chunks ($result was empty). // NOTE: Thanks to all of the validation above, this can ONLY happen // when input consisted entirely of underscores with nothing after that. if ( $ chunkCount === 0 ) { // Insert a fake, empty element to act as the first chunk, to ensure // that we have something to insert the underscores into. $ chunks [ ] = '' ; $ chunkCount ++ ; } // Lowercase the leading uppercase of 1st chunk (whatever is in there), // since that chunk needs lowercase in both snake_case and camelCase. // Example: "Message" & "List" => "message" & "List" $ chunks [ 0 ] = lcfirst ( $ chunks [ 0 ] ) ; // If there were any leading underscores, prepend all of them to the 1st // chunk, which ensures that they become part of the first chunk. // Example: "__message" & "List" if ( $ leadingUnderscores > 0 ) { $ chunks [ 0 ] = str_repeat ( '_' , $ leadingUnderscores ) . $ chunks [ 0 ] ; } // Now let's create the snake_case and camelCase variable names. // The property name chunks are already in perfect format for camelCase. // The first chunk starts with a lowercase letter, and all other chunks // start with an uppercase letter. So generate the camelCase property // name version first. But only if there are 2+ chunks. Otherwise NULL. // NOTE: Turns "i,Tunes,Item" into "iTunesItem", and "foo" into NULL. $ camelPropName = $ chunkCount >= 2 ? implode ( '' , $ chunks ) : null ; // Now make the second property name chunk and onwards into lowercase, // and then generate the all-lowercase "snake_case" property name. // NOTE: Turns "some,Property,Name" into "some_property_name". for ( $ i = 1 ; $ i < $ chunkCount ; ++ $ i ) { $ chunks [ $ i ] = lcfirst ( $ chunks [ $ i ] ) ; // Only first letter can be UC. } $ snakePropName = implode ( '_' , $ chunks ) ; // Return the final snake_case and camelCase property names. return [ 'snake' => $ snakePropName , 'camel' => $ camelPropName , ] ; }
Converts a FunctionCase name to snake and camel properties.

See input/output examples in class documentation above.

@param string $funcCase

@return array|bool Associative array with `snake` & `camel` elements if
successful, otherwise `FALSE`.
Converts a FunctionCase name to snake and camel properties .