<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
namespace Friendica\Util;
-use Friendica\Model\Group;
+use Friendica\Model\Circle;
/**
* Util class for ACL formatting
final class ACLFormatter
{
/**
- * Turn user/group ACLs stored as angle bracketed text into arrays
+ * Turn user/circle ACLs stored as angle bracketed text into arrays
*
* @param string|null $acl_string A angle-bracketed list of IDs
*
* @return array The array based on the IDs (empty in case there is no list)
*/
- public function expand(string $acl_string = null)
+ public function expand(string $acl_string = null): array
{
// In case there is no ID list, return empty array (=> no ACL set)
if (empty($acl_string)) {
// turn string array of angle-bracketed elements into numeric array
// e.g. "<1><2><3>" => array(1,2,3);
- preg_match_all('/<(' . Group::FOLLOWERS . '|'. Group::MUTUALS . '|[0-9]+)>/', $acl_string, $matches, PREG_PATTERN_ORDER);
+ preg_match_all('/<(' . Circle::FOLLOWERS . '|'. Circle::MUTUALS . '|[0-9]+)>/', $acl_string, $matches, PREG_PATTERN_ORDER);
return $matches[1];
}
* @param string|null $acl_string
* @return string
*/
- public function sanitize(string $acl_string = null)
+ public function sanitize(string $acl_string = null): string
{
if (empty($acl_string)) {
return '';
if (intval($item)) {
$item = '<' . intval($item) . '>';
// The item is a allowed ACL character
- } elseif (in_array($item, [Group::FOLLOWERS, Group::MUTUALS])) {
+ } elseif (in_array($item, [Circle::FOLLOWERS, Circle::MUTUALS])) {
$item = '<' . $item . '>';
// The item is already a ACL string
} elseif (preg_match('/<\d+?>/', $item)) {
*
* @return string
*/
- function toString($permissions) {
+ function toString($permissions): string
+ {
$return = '';
if (is_array($permissions)) {
$item = $permissions;
+ } elseif (empty($permissions)) {
+ return '';
} else {
$item = explode(',', $permissions);
}