| Conditions | 4 |
| Paths | 1 |
| Total Lines | 54 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
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 |
||
| 49 | public function __construct(array $urlParams = array()) { |
||
| 50 | parent::__construct('deck', $urlParams); |
||
| 51 | |||
| 52 | $container = $this->getContainer(); |
||
| 53 | $server = $container->getServer(); |
||
| 54 | |||
| 55 | $container->registerService('SharingMiddleware', function() use ($server) { |
||
| 56 | return new SharingMiddleware( |
||
| 57 | $server->getLogger(), |
||
| 58 | $server->getConfig() |
||
| 59 | ); |
||
| 60 | }); |
||
| 61 | $container->registerMiddleWare('SharingMiddleware'); |
||
| 62 | |||
| 63 | $container->registerService('databaseType', function($container) { |
||
| 64 | return $container->getServer()->getConfig()->getSystemValue('dbtype', 'sqlite'); |
||
| 65 | }); |
||
| 66 | |||
| 67 | $container->registerService('database4ByteSupport', function($container) { |
||
| 68 | return $container->getServer()->getDatabaseConnection()->supports4ByteText(); |
||
| 69 | }); |
||
| 70 | |||
| 71 | // Delete user/group acl entries when they get deleted |
||
| 72 | /** @var IUserManager $userManager */ |
||
| 73 | $userManager = $server->getUserManager(); |
||
| 74 | $userManager->listen('\OC\User', 'postDelete', function(IUser $user) use ($container) { |
||
|
|
|||
| 75 | // delete existing acl entries for deleted user |
||
| 76 | /** @var AclMapper $aclMapper */ |
||
| 77 | $aclMapper = $container->query(AclMapper::class); |
||
| 78 | $acls = $aclMapper->findByParticipant(Acl::PERMISSION_TYPE_USER, $user->getUID()); |
||
| 79 | foreach ($acls as $acl) { |
||
| 80 | $aclMapper->delete($acl); |
||
| 81 | } |
||
| 82 | // delete existing user assignments |
||
| 83 | $assignmentMapper = $container->query(AssignedUsersMapper::class); |
||
| 84 | $assignments = $assignmentMapper->findByUserId($user->getUID()); |
||
| 85 | foreach ($assignments as $assignment) { |
||
| 86 | $assignmentMapper->delete($assignment); |
||
| 87 | } |
||
| 88 | }); |
||
| 89 | |||
| 90 | /** @var IUserManager $userManager */ |
||
| 91 | $groupManager = $server->getGroupManager(); |
||
| 92 | $groupManager->listen('\OC\Group', 'postDelete', function(IGroup $group) use ($container) { |
||
| 93 | /** @var AclMapper $aclMapper */ |
||
| 94 | $aclMapper = $container->query(AclMapper::class); |
||
| 95 | $aclMapper->findByParticipant(Acl::PERMISSION_TYPE_GROUP, $group->getGID()); |
||
| 96 | $acls = $aclMapper->findByParticipant(Acl::PERMISSION_TYPE_GROUP, $group->getGID()); |
||
| 97 | foreach ($acls as $acl) { |
||
| 98 | $aclMapper->delete($acl); |
||
| 99 | } |
||
| 100 | }); |
||
| 101 | |||
| 102 | } |
||
| 103 | |||
| 150 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.