Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I needed LSB this for the following scenario: </p> <ul> <li>Imagine you're building a "mail processor" daemon that downloads the message from an email server, classifies it, parses it, saves it, and then does something, depending on the type of the message. </li> <li>Class hierarchy: you have a base Message class, with children "BouncedMessage" and "AcceptedMessage".</li> <li>Each of the message types has its own way to persist itself on disk. For example, all messages of type BouncedMessage try to save itself as BouncedMessage-id.xml. AcceptedMessage, on the other hand, needs to save itself differently - as AcceptedMessage-timestamp.xml. The important thing here is that the logic for determining the filename pattern is different for different subclasses, but <strong>shared</strong> for all items within the subclass. That's why it makes sense for it to be in a static method.</li> <li>Base Message class has an abstract static method (yes, abstract <em>AND</em> static) "save". BouncedMessage implements this method with a concrete static method. Then, inside the class that actually retrieves the message, you can call "::save()"</li> </ul> <p>If you want to learn more about the subject:</p> <ul> <li><a href="http://www.qcodo.com/forums/topic.php/2356" rel="nofollow noreferrer">http://www.qcodo.com/forums/topic.php/2356</a></li> <li><a href="http://community.livejournal.com/php/585907.html" rel="nofollow noreferrer">http://community.livejournal.com/php/585907.html</a></li> <li><a href="http://bugs.php.net/bug.php?id=42681" rel="nofollow noreferrer">http://bugs.php.net/bug.php?id=42681</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload