php - Is it acceptable to use a wrapper class to hide errors? -


Is it OK to wrap a global array in the class to hide undefined errors (and Returning wrong) with OOP? If not, then why?

I am using the following input wrapper class. Primarily using it with my FormValidator class, so that I do not want to use / use the amount of input for the isset () to write.

  Class Input {Private $ _ Sons; Public function __ composition (array $ source) {$ this- & gt; _source = $ source; } Public function is present () {Return! Lower ($ this-> _source); } Get public function ($ input) {return (isset ($ this- & gt; _source [$ input]))? $ This- & gt; _source [$ input]: wrong; }}  

Good comments on your question, there are different ways and maybe The better built-in concept you can use to solve the problem of use.

But to answer your question about OOP practices in PHP, I certainly argue that the hiding errors in your wrapper class are legal.

I consider this as a black box and the concept of that error is not known because your interface does not document it.

Dealing with an error can be implemented within your casing, as the errors do not need to be known from outside.

It's okay, but all the errors should be handled normally and should be hidden or swallowing them may be strange behavior.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -