Example #1
0
 /**
  * Get the static instance of this factory.
  *
  * @return MockFactory The static factory.
  */
 public static function instance()
 {
     if (!self::$instance) {
         self::$instance = new self(Sequencer::sequence('mock-label'), MockGenerator::instance(), HandleFactory::instance(), FeatureDetector::instance());
     }
     return self::$instance;
 }
Example #2
0
 /**
  * Get the generated source code of the mock class.
  *
  * Calling this method will finalize the mock builder.
  *
  * @param MockGenerator|null $generator The mock generator to use.
  *
  * @return string        The source code.
  * @throws MockException If the mock generation fails.
  */
 public function source(MockGenerator $generator = null)
 {
     if (!$generator) {
         $generator = MockGenerator::instance();
     }
     return $generator->generate($this->definition());
 }