Symfony\Component\PropertyAccess\PropertyAccessor::findAdderAndRemover PHP Method

findAdderAndRemover() private method

Searches for add and remove methods.
private findAdderAndRemover ( ReflectionClass $reflClass, array $singulars ) : array | null
$reflClass ReflectionClass The reflection class for the given object
$singulars array The singular form of the property name or null
return array | null An array containing the adder and remover when found, null otherwise
    private function findAdderAndRemover(\ReflectionClass $reflClass, array $singulars)
    {
        foreach ($singulars as $singular) {
            $addMethod = 'add'.$singular;
            $removeMethod = 'remove'.$singular;

            $addMethodFound = $this->isMethodAccessible($reflClass, $addMethod, 1);
            $removeMethodFound = $this->isMethodAccessible($reflClass, $removeMethod, 1);

            if ($addMethodFound && $removeMethodFound) {
                return array($addMethod, $removeMethod);
            }
        }
    }