['ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'], 'ROLE_SUPER_ADMIN' => ['ROLE_ADMIN'], ]); $group = new Group('Admins'); $group->addRole('ROLE_ADMIN'); $groupByName = $roleHierarchy->getByName('Admins'); var_dump($groupByName); ?>In this example, the getByName method is used with the RoleHierarchy package of the Symfony component. The code creates a new group named "Admins" and adds the role "ROLE_ADMIN" to it. It then uses the getByName method to get the group object for the "Admins" group and stores it in the $groupByName variable. Finally, the code uses the var_dump function to display the contents of the $groupByName variable. Overall, the getByName method is a simple but powerful tool for retrieving group objects based on their names in PHP. The package/library used in this example is the Symfony component.