تخطَّ إلى المحتوى

God class (ARCH7189)

هذا المحتوى غير متوفر بلغتك بعد.

Key php.quality.god-class · Severity warning · Category quality

Classes with many methods and fields usually take on several unrelated responsibilities, have low cohesion, and are hard to maintain. Split the responsibilities into separate classes.

<?php
class UserManager
{
public function register() { /* ... */ }
public function login() { /* ... */ }
public function sendEmail() { /* ... */ }
public function renderProfile() { /* ... */ }
public function chargeCard() { /* ... */ }
public function generateReport() { /* ... */ }
// ... dozens of unrelated methods ...
}
<?php
class AuthService { public function register() {} public function login() {} }
class Mailer { public function send() {} }
class BillingService { public function charge() {} }

Separate unrelated responsibilities into single-purpose classes.