| Conditions | 13 | 
| Paths | 48 | 
| Total Lines | 61 | 
| Code Lines | 36 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 1 | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 112 | 	public function setGroupMemberSet($principal, array $members) { | 
            ||
| 113 | list($principalUri, $target) = \Sabre\Uri\split($principal);  | 
            ||
| 114 | |||
| 115 | 		if ($target !== 'calendar-proxy-write' && $target !== 'calendar-proxy-read') { | 
            ||
| 116 | 			throw new Exception('Setting members of the group is not supported yet'); | 
            ||
| 117 | }  | 
            ||
| 118 | |||
| 119 | $masterPrincipalArray = $this->getPrincipalByPath($principalUri);  | 
            ||
| 120 | 		if (!$masterPrincipalArray) { | 
            ||
| 121 | 			throw new Exception('Principal not found'); | 
            ||
| 122 | }  | 
            ||
| 123 | |||
| 124 | $permission = ProxyMapper::PERMISSION_READ;  | 
            ||
| 125 | 		if ($target === 'calendar-proxy-write') { | 
            ||
| 126 | $permission |= ProxyMapper::PERMISSION_WRITE;  | 
            ||
| 127 | }  | 
            ||
| 128 | |||
| 129 | list($prefix, $owner) = \Sabre\Uri\split($principalUri);  | 
            ||
| 130 | $proxies = $this->proxyMapper->getProxiesOf($principalUri);  | 
            ||
| 131 | |||
| 132 | 		foreach ($members as $member) { | 
            ||
| 133 | list($prefix, $name) = \Sabre\Uri\split($member);  | 
            ||
| 134 | |||
| 135 | 			if ($prefix !== $this->principalPrefix) { | 
            ||
| 136 | 				throw new Exception('Invalid member group prefix: ' . $prefix); | 
            ||
| 137 | }  | 
            ||
| 138 | |||
| 139 | $principalArray = $this->getPrincipalByPath($member);  | 
            ||
| 140 | 			if (!$principalArray) { | 
            ||
| 141 | 				throw new Exception('Principal not found'); | 
            ||
| 142 | }  | 
            ||
| 143 | |||
| 144 | $found = false;  | 
            ||
| 145 | 			foreach ($proxies as $proxy) { | 
            ||
| 146 | 				if ($proxy->getProxyId() === $member) { | 
            ||
| 147 | $found = true;  | 
            ||
| 148 | $proxy->setPermissions($proxy->getPermissions() | $permission);  | 
            ||
| 149 | $this->proxyMapper->update($proxy);  | 
            ||
| 150 | |||
| 151 | 					$proxies = array_filter($proxies, function(Proxy $p) use ($proxy) { | 
            ||
| 152 | return $p->getId() !== $proxy->getId();  | 
            ||
| 153 | });  | 
            ||
| 154 | break;  | 
            ||
| 155 | }  | 
            ||
| 156 | }  | 
            ||
| 157 | |||
| 158 | 			if ($found === false) { | 
            ||
| 159 | $proxy = new Proxy();  | 
            ||
| 160 | $proxy->setOwnerId($principalUri);  | 
            ||
| 161 | $proxy->setProxyId($member);  | 
            ||
| 162 | $proxy->setPermissions($permission);  | 
            ||
| 163 | $this->proxyMapper->insert($proxy);  | 
            ||
| 164 | }  | 
            ||
| 165 | }  | 
            ||
| 166 | |||
| 167 | // Delete all remaining proxies  | 
            ||
| 168 | 		foreach ($proxies as $proxy) { | 
            ||
| 169 | // Write and Read Proxies have individual requests,  | 
            ||
| 170 | // so only delete proxies of this permission  | 
            ||
| 171 | 			if ($proxy->getPermissions() === $permission) { | 
            ||
| 172 | $this->proxyMapper->delete($proxy);  | 
            ||
| 173 | }  | 
            ||
| 224 |