F
F
Forever Extreme2021-04-09 14:42:11
PHP
Forever Extreme, 2021-04-09 14:42:11

How to properly implement OOP structure?

Hello! Please advise how best to do it. My task is to take information from the database and write it into an xml file, after converting it according to the requirements of the site (the main problem is that the names of the fields in the database and on the site are different), to which I send the feed. information of this kind.
We have motorcycle, car, truck, etc. (as in rights) and they can be rented or sold.
I wrote a class that receives an array with data from the database

function __construct($data) {
$this->data = $data;
}

With these data I later also work. I wrote functions for each option. (motorbike sale, motorcycle rental, etc.)
public function motoSale($value) {
// какое-то преобразование
return $dataForXml;
}
public function motoRent($value) {
// какое-то преобразование
return $dataForXml;

Previously, I separated the common properties into another function so as not to duplicate
public function general($val) {
// что-то делаем
return $generalData;
}

The problem is that individual functions (motoSale, motoRent ....) are still voluminous and greatly inflate the class (500 lines)
Is it possible to put them in a separate file?
PS: there is an idea to use a template engine, there you can call a template that suits your requirements,
but now I don’t have the opportunity to use it, that’s why I turned to you with a question)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2021-04-09
@SilenceOfWinter

and oops where is it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question