Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
204 views
in Technique[技术] by (71.8m points)

php - where to find "template" interfaces?

i wonder where one can find template interfaces.

eg. i am creating these classes that implements iLog:

 DatabaseLog
 ScreenLog
 FileLog

i wonder what methods should a typical Log class have?

is there a set of interfaces you could just implement/learn from rather than reinvent the wheel and have to think about the method names.

eg. Interfaces:

 iLog
 iDatabase
 iErrorMessage
 etc.

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

PHP defines the following interfaces (should, but may not be complete):

  • Traversable — The Traversable interface
  • Iterator — The Iterator interface
  • IteratorAggregate — The IteratorAggregate interface
  • ArrayAccess — The ArrayAccess interface
  • Serializable — The Serializable interface
  • Countable — The Countable interface
  • OuterIterator — The OuterIterator interface
  • RecursiveIterator — The RecursiveIterator interface
  • SeekableIterator — The SeekableIterator interface
  • SplObserver — The SplObserver interface
  • SplSubject — The SplSubject interface

See

As for your Logger Interface, I'd say it should have a method log($message, level) and nothing else.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...