PHP Classes

File: lib/Injector/Profiler.php

Recommend this page to a friend!
  Classes of Emmanuel Antico   Injector   lib/Injector/Profiler.php   Download  
File: lib/Injector/Profiler.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Injector
Inject dependencies defined in annotation comments
Author: By
Last change:
Date: 9 years ago
Size: 926 bytes
 

Contents

Class file image Download
<?php
namespace Injector;

/**
 * Manages a collection of class profiles
 * @author emaphp
 * @package Injector
 */
class Profiler {
   
/**
     * Class profiles list
     * @var array
     */
   
protected static $profiles = array();
   
   
/**
     * Obtains a class profile by its name
     * @param string $classname
     * @throws \RuntimeException
     */
   
public static function getClassProfile($classname) {
        if (!
is_string($classname) || empty($classname)) {
            throw new \
InvalidArgumentException("Argument is not a valid class name");
        }
       
       
//check if is already stored
       
if (array_key_exists($classname, self::$profiles)) {
            return
self::$profiles[$classname];
        }
       
       
//validate classname
        
if (!class_exists($classname, true)) {
             throw new \
RuntimeException("Class %s could not be found");
         }
       
       
//build profile and return
       
self::$profiles[$classname] = new ClassProfile($classname);
        return
self::$profiles[$classname];
    }
}