1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00

Redundant code cleanup

This commit is contained in:
David Bomba 2020-11-04 00:27:41 +11:00
parent 552ac4ee8f
commit 13a00fc897
22 changed files with 22 additions and 232 deletions

View File

@ -34,24 +34,6 @@ class BaseRepository
use MakesHash;
use SavesDocuments;
/**
* @return null
*/
public function getClassName()
{
return null;
}
/**
* @return mixed
*/
private function getInstance()
{
$className = $this->getClassName();
return new $className();
}
/**
* @param $entity
* @param $type
@ -153,25 +135,6 @@ class BaseRepository
return count($entities);
}
/**
* @param $ids
*
* @return mixed
*/
public function findByPublicIds($ids)
{
return $this->getInstance()->scope($ids)->get();
}
/**
* @param $ids
*
* @return mixed
*/
public function findByPublicIdsWithTrashed($ids)
{
return $this->getInstance()->scope($ids)->withTrashed()->get();
}
public function getInvitation($invitation, $resource)
{

View File

@ -39,17 +39,7 @@ class ClientRepository extends BaseRepository
{
$this->contact_repo = $contact_repo;
}
/**
* Gets the class name.
*
* @return string The class name.
*/
public function getClassName()
{
return Client::class;
}
/**
* Saves the client and its contacts.
*

View File

@ -23,16 +23,6 @@ class CompanyRepository extends BaseRepository
{
}
/**
* Gets the class name.
*
* @return string The class name.
*/
public function getClassName()
{
return Company::class;
}
/**
* Saves the client and its contacts.
*

View File

@ -30,15 +30,6 @@ class CreditRepository extends BaseRepository
{
}
/**
* Gets the class name.
*
* @return string The class name.
*/
public function getClassName()
{
return Credit::class;
}
/**
* Saves the client and its contacts.

View File

@ -11,30 +11,10 @@
namespace App\Repositories;
use App\Libraries\MultiDB;
use App\Models\Activity;
use App\Models\Backup;
use App\Models\Client;
use App\Models\Design;
use App\Models\Invoice;
use App\Models\User;
use App\Utils\Traits\MakesInvoiceHtml;
use Illuminate\Support\Facades\Log;
/**
* Class for activity repository.
* Class for DesignRepository .
*/
class DesignRepository extends BaseRepository
{
use MakesInvoiceHtml;
/**
* Gets the class name.
*
* @return string The class name.
*/
public function getClassName()
{
return Design::class;
}
}

View File

@ -19,15 +19,6 @@ use App\Utils\Ninja;
*/
class DocumentRepository extends BaseRepository
{
/**
* Gets the class name.
*
* @return string The class name.
*/
public function getClassName()
{
return Document::class;
}
public function delete($document)
{

View File

@ -24,19 +24,6 @@ class ExpenseRepository extends BaseRepository
{
use GeneratesCounter;
public function __construct()
{
}
/**
* Gets the class name.
*
* @return string The class name.
*/
public function getClassName()
{
return Expense::class;
}
/**
* Saves the expense and its contacts.

View File

@ -12,21 +12,9 @@
namespace App\Repositories;
use App\Models\GroupSetting;
use App\Utils\Traits\MakesHash;
class GroupSettingRepository extends BaseRepository
{
use MakesHash;
/**
* Gets the class name.
*
* @return string The class name.
*/
public function getClassName()
{
return GroupSetting::class;
}
public function save($data, GroupSetting $group_setting) :?GroupSetting
{

View File

@ -27,23 +27,14 @@ class InvoiceRepository extends BaseRepository
{
use MakesHash;
/**
* Gets the class name.
*
* @return string The class name.
*/
public function getClassName()
{
return Invoice::class;
}
/**
* Saves the invoices.
*
* @param array. $data The invoice data
* @param InvoiceSum|Invoice $invoice The invoice
* @param array $data The invoice data
* @param Invoice $invoice The invoice
*
* @return Invoice|InvoiceSum|null Returns the invoice object
* @return Invoice|null Returns the invoice object
*/
public function save($data, Invoice $invoice):?Invoice
{

View File

@ -48,11 +48,6 @@ class PaymentMigrationRepository extends BaseRepository
$this->activity_repo = new ActivityRepository();
}
public function getClassName()
{
return Payment::class;
}
/**
* Saves and updates a payment. //todo refactor to handle refunds and payments.
*

View File

@ -41,15 +41,6 @@ class PaymentRepository extends BaseRepository
$this->credit_repo = $credit_repo;
}
/**
* @return string
*/
public function getClassName()
{
return Payment::class;
}
/**
* Saves and updates a payment. //todo refactor to handle refunds and payments.
*

View File

@ -19,11 +19,6 @@ class ProductRepository extends BaseRepository
{
use SavesDocuments;
public function getClassName()
{
return Product::class;
}
/**
* @param array $data
* @param Product $product

View File

@ -19,13 +19,4 @@ use App\Models\Project;
class ProjectRepository extends BaseRepository
{
/**
* Gets the class name.
*
* @return string The class name.
*/
public function getClassName()
{
return Project::class;
}
}

View File

@ -27,12 +27,7 @@ use Illuminate\Http\Request;
*/
class QuoteRepository extends BaseRepository
{
use MakesHash;
public function getClassName()
{
return Quote::class;
}
public function save($data, Quote $quote) : ?Quote
{

View File

@ -20,10 +20,6 @@ use Illuminate\Http\Request;
*/
class RecurringInvoiceRepository extends BaseRepository
{
public function getClassName()
{
return RecurringInvoice::class;
}
public function save($data, RecurringInvoice $invoice) : ?RecurringInvoice
{

View File

@ -20,10 +20,7 @@ use Illuminate\Http\Request;
*/
class RecurringQuoteRepository extends BaseRepository
{
public function getClassName()
{
return RecurringQuote::class;
}
public function save(Request $request, RecurringQuote $quote) : ?RecurringQuote
{
@ -31,13 +28,10 @@ class RecurringQuoteRepository extends BaseRepository
$quote->save();
$quote_calc = new InvoiceSum($quote, $quote->settings);
$quote_calc = new InvoiceSum($quote);
$quote = $quote_calc->build()->getQuote();
//fire events here that cascading from the saving of an Quote
//ie. client balance update...
return $quote;
}
}

View File

@ -23,19 +23,6 @@ class TaskRepository extends BaseRepository
{
use GeneratesCounter;
public function __construct()
{
}
/**
* Gets the class name.
*
* @return string The class name.
*/
public function getClassName()
{
return Task::class;
}
/**
* Saves the task and its contacts.

View File

@ -15,15 +15,7 @@ use App\Models\CompanyToken;
class TokenRepository extends BaseRepository
{
/**
* Gets the class name.
*
* @return string The class name.
*/
public function getClassName()
{
return CompanyToken::class;
}
/**
* Saves the companytoken.

View File

@ -27,24 +27,15 @@ class UserRepository extends BaseRepository
{
use MakesHash;
/**
* Gets the class name.
*
* @return string The class name.
*/
public function getClassName()
{
return User::class;
}
/**
* Saves the user and its contacts.
*
* @param array $data The data
* @param \App\Models\user $user The user
* @param \App\Models\User $user The user
*
* @param bool $unset_company_user
* @return user|\App\Models\user|null user Object
* @return \App\Models\User user Object
*/
public function save(array $data, User $user, $unset_company_user = false)
{

View File

@ -13,7 +13,7 @@ namespace App\Repositories;
use App\Factory\VendorFactory;
use App\Models\Vendor;
use App\Repositories\VSendorContactRepository;
use App\Repositories\VendorContactRepository;
use App\Utils\Traits\GeneratesCounter;
use Illuminate\Http\Request;
@ -23,37 +23,24 @@ use Illuminate\Http\Request;
class VendorRepository extends BaseRepository
{
use GeneratesCounter;
/**
* @var vendorContactRepository
*/
protected $contact_repo;
/**
* vendorController constructor.
* @param vendorContactRepository $contact_repo
* VendorContactRepository constructor.
*/
public function __construct(VendorContactRepository $contact_repo)
{
$this->contact_repo = $contact_repo;
}
/**
* Gets the class name.
*
* @return string The class name.
*/
public function getClassName()
{
return Vendor::class;
}
/**
* Saves the vendor and its contacts.
*
* @param array $data The data
* @param \App\Models\vendor $vendor The vendor
* @param \App\Models\Vendor $vendor The vendor
*
* @return vendor|\App\Models\vendor|null vendor Object
* @return vendor|\App\Models\Vendor|null Vendor Object
* @throws \Laracasts\Presenter\Exceptions\PresenterException
*/
public function save(array $data, Vendor $vendor) : ?Vendor
@ -70,7 +57,7 @@ class VendorRepository extends BaseRepository
$vendor->save();
if (isset($data['contacts'])) {
$contacts = $this->contact_repo->save($data, $vendor);
$this->contact_repo->save($data, $vendor);
}
if (empty($data['name'])) {

View File

@ -40,7 +40,7 @@ class CreateInvitations extends AbstractService
$ii->credit_id = $this->credit->id;
$ii->client_contact_id = $contact->id;
$ii->save();
} elseif ($invitation && ! $contact->send_email) {
} elseif (! $contact->send_email) {
$invitation->delete();
}
});

View File

@ -61,6 +61,11 @@
<directory name="app" />
</errorLevel>
</InvalidNullableReturnType>
<ImplementedReturnTypeMismatch>
<errorLevel type="suppress">
<directory name="app" />
</errorLevel>
</ImplementedReturnTypeMismatch>
</issueHandlers>