Create a profiled name from an object argument

@param \stdClass $arg               Object argument
@param string|boolean|null $profile Profile

@return \stdClass Profiled name
@throws InvalidArgumentException If the name is missing
17102
protected static function createProfiledNameFromObject($arg, &$profile)
    {
        // If the name is invalid
        if (!isset($arg->name)) {
            throw new InvalidArgumentException(
                InvalidArgumentException::INVALID_TYPE_PROPERTY_NAME_STR,
                InvalidArgumentException::INVALID_TYPE_PROPERTY_NAME
            );
        }

        if (isset($arg->profile)) {
            $profile = trim($arg->profile) ?: null;
        }

        return self::createProfiledNameFromString($arg->name, $profile);
    }
999023
public function make($name, array $args = [])
    {
        list($className, $normalizedClass) = $this->resolveAlias($name);

        if (isset($this->inProgressMakes[$normalizedClass])) {
            throw new InjectionException(
                $this->inProgressMakes,
                sprintf(
                    InjectorException::M_CYCLIC_DEPENDENCY,
                    $className
                ),
                InjectorException::E_CYCLIC_DEPENDENCY
            );
        }

        $this->inProgressMakes[$normalizedClass] = count($this->inProgressMakes);

        // isset() is used specifically here because classes may be marked as "shared" before an
        // instance is stored. In these cases the class is "shared," but it has a null value and
        // instantiation is needed.
        if (isset($this->shares[$normalizedClass])) {
            unset($this->inProgressMakes[$normalizedClass]);

            return $this->shares[$normalizedClass];
        }

        if (isset($this->delegates[$normalizedClass])) {
            $executable         = $this->buildExecutable($this->delegates[$normalizedClass]);
            $reflectionFunction = $executable->getCallableReflection();
            $args               = $this->provisionFuncArgs($reflectionFunction, $args);
            $obj                = call_user_func_array(array($executable, '__invoke'), $args);
        } else {
            $obj = $this->provisionInstance($className, $normalizedClass, $args);
        }

        $obj = $this->prepareInstance($obj, $normalizedClass);

        if (array_key_exists($normalizedClass, $this->shares)) {
            $this->shares[$normalizedClass] = $obj;
        }

        unset($this->inProgressMakes[$normalizedClass]);

        return $obj;
    }
1015537
public function getCacheInstance(?string $profile = null, array $options = []): CacheInterface
    {
        $config = $this->config;

        $config = $config->extract('cache');

        $profile = $profile ?: $config->get('default', 'global');

        if ($config->exists('profiles')) {
            $config = $config->extract('profiles.' . $profile);
        }

        $options = array_merge([
            'name' => 'windwalker',
            'storage' => 'array',
            'serializer' => 'php',
            'force_enabled' => false
        ], $config->toArray(), $options);

        return $this->getCache(
            $options['name'],
            $options['storage'],
            $options['serializer'],
            $options
        );
    }
1205123
public static function create($name, ...$args)
    {
        $name = static::getClass($name);

        $class = static::findClass($name);

        if ($class) {
            return static::createObject($class, ...$args);
        }

        return null;
    }
151888
private static function profile_eval_ish( $assoc_args, $profile_callback, $order = 'ASC', $orderby = null ) {
		$hook   = Utils\get_flag_value( $assoc_args, 'hook' );
		$type   = $focus = false;
		$fields = array();
		if ( $hook ) {
			$type = 'hook';
			if ( true !== $hook ) {
				$focus    = $hook;
				$fields[] = 'callback';
				$fields[] = 'location';
			} else {
				$fields[] = 'hook';
			}
		}
		$profiler = new Profiler( $type, $focus );
		$profiler->run();
		if ( $hook ) {
			$profile_callback();
			$loggers = $profiler->get_loggers();
		} else {
			$logger = new Logger();
			$logger->start();
			$profile_callback();
			$logger->stop();
			$loggers = array( $logger );
		}
		$fields    = array_merge(
			$fields,
			array(
				'time',
				'query_time',
				'query_count',
				'cache_ratio',
				'cache_hits',
				'cache_misses',
				'request_time',
				'request_count',
			)
		);
		$formatter = new Formatter( $assoc_args, $fields );
		$formatter->display_items( $loggers, false, $order, $orderby );
	}
1203735
public function create($name, $scratchDir, $processor, $namer, array $sources, array $destinations)
    {
        return new Profile(
            $name,
            $scratchDir,
            $this->getProcessor($processor),
            $this->getNamer($namer),
            $this->getSources($sources),
            $this->getDestinations($destinations)
        );
    }
312318
public static function appProfileName($project, $instance, $appProfile)
    {
        return self::getAppProfileNameTemplate()->render([
            'project' => $project,
            'instance' => $instance,
            'app_profile' => $appProfile,
        ]);
    }
994735
public function profile($profile = null)
    {
        if ($profile === null) {
            return $this->_providerProfile;
        }

        $this->_providerProfile = $profile;
    }
39590
public static function init ($name = null, ...$args) {
		$name = implode('<>', (array) ($name ?? static::$multitonDefaultName));
		$instance = (static::$multitonInstances[static::class][$name] ?? static::$multitonInstances[static::class][$name] = new static(...$args));
		$instance->multitonName = $name;
		return $instance;
	}
743385
public function getProfileAttribute($attributeName)
    {
        if (isset($this->profileData[$attributeName])) {
            $attributeObj = $this->profileData[$attributeName];
            return $attributeObj instanceof Attribute ? $attributeObj : null;
        }
        return null;
    }
654586
public function createProcessor($classOrName, $args = [])
    {
        $classes = [
            $classOrName,
            '\\Monolog\\Processor\\' . $classOrName
        ];

        foreach ($classes as $class)
        {
            if (class_exists($class))
            {
                return (new ReflectionClass($class))->newInstanceArgs($args);
            }
        }

        throw new InvalidArgumentException("Monolog processor [$classOrName] does not exist.");
    }
242969
public function setProfile($profile) {
		if (is_string($profile)) {
			$profile = new Profile($profile);
		}
		$this->profile = $profile;
		return $this;
	}
572877
public function create($definition, array $args = array())
    {
        $className = $definition;

        if(is_array($definition))
        {
            $className = $definition['class'];

            if(isset($definition['arguments']))
                $args = array_merge($args, $definition['arguments']);
        }
        else
        {
            $className = $definition;
        }

        $className = $this->buildClassName($className);

        // class name does not exists in the given path.
        if(!class_exists($className))
            throw new \Exedra\Exception\NotFoundException('Class named ['.$className.'] does not exists.');

        if(count($args))
        {
            $reflection	= new \ReflectionClass($className);

            $instance	= $reflection->newInstanceArgs($args);
        }
        else
        {
            $instance	= new $className;
        }

        return $instance;
    }
591180
def do_profile(self,args):
        
        parser = CommandArgumentParser("profile")
        parser.add_argument(dest="profile",help="Profile name")
        parser.add_argument('-v','--verbose',dest="verbose",action='store_true',help='verbose')
        args = vars(parser.parse_args(args))

        profile = args['profile']
        verbose = args['verbose']
        if verbose:
            print "Selecting profile '{}'".format(profile)

        selectedProfile = {}
        if profile in Config.config['profiles']:
            selectedProfile = Config.config['profiles'][profile]

        selectedProfile['name'] = profile
        Config.config['selectedProfile'] = selectedProfile

        awsProfile = profile
        if 'awsProfile' in selectedProfile:
            awsProfile = selectedProfile['awsProfile']
        AwsConnectionFactory.resetInstance(profile=awsProfile)
1243518
public function run(array $data, $profileName = null)
    {
        if ($profileName) {
            $this->setProfile($profileName);
        }
        if (!$this->currentProfile) {
            throw new \InvalidArgumentException("No profile set. Cannot run validation.");
        }
        return $this->profiles[$this->currentProfile]->run($data);
    }
208234
public static function createFromName($name)
    {
        $value = array_search($name, static::$names, true);

        if (!$value) {
            throw new InvalidArgumentException(sprintf(
                'Level with name "%s" is not in list: %s',
                $name,
                implode(', ', static::$names)
            ));
        }

        return new static($value);
    }
1231195
protected static function consumeNonScalarProfiledName($arg, &$profile)
    {
        // If it's an object argument
        if (is_object($arg)) {
            return self::createProfiledNameFromObject($arg, $profile);
        }

        // Else: It must be an array
        return self::createProfiledNameFromArray($arg, $profile);
    }