Build a spec object given the method and args
@param  string $methodName
@param  array  $with
@return Spec
326318
protected function initSpec($methodName, array $with)
    {
        if ($this->in_static_mode) {
            return new StaticSpec($this->testCase, $this->className, $methodName, $with, Shmock::$policies);
        } else {
            return new InstanceSpec($this->testCase, $this->className, $methodName, $with, Shmock::$policies);
        }
    }
988171
public static function objectsMethodValues(array $objectArray, string $methodName): array
    {
        $methodValues = [];

        foreach ($objectArray as $object) {
            $methodValues[] = $object->$methodName();
        }

        return $methodValues;
    }
1128292
protected function invokeMethod(&$object, $methodName, array $parameters = [])
    {
        return $this->getMethodInstance($object, $methodName)->invokeArgs($object, $parameters);
    }
984031
public function withCount($withs)
    {
        if ( ! is_array($withs)) {
            $withs = func_get_args();
        }

        $this->withCounts = $withs;

        return $this;
    }
1312854
public function method(string $methodName): PropertyColumnDefiner
    {
        return new PropertyColumnDefiner($this, null, function (Column $column) use ($methodName) {
            $this->methodColumnMap[$methodName] = $column->getName();
            $this->addColumn($column);
        });
    }
170351
public function with($with)
    {
        if (!is_array($with)) {
            $with = [$with];
        }

        foreach ($with as $name => $fields) {
            if (is_numeric($name)) {
                $name = $fields;
            }

            if ($this->getModel()->getMeta()->hasRelatedField($name)) {
                $this->with[] = $name;
            }
        }

        return $this;
    }
260877
protected function getReflectionMethod($className, $methodName = '__construct') {
		if (isset($this->reflectionMethods[$className])
			&& array_key_exists($methodName, $this->reflectionMethods[$className])
		) {
			return $this->reflectionMethods[$className][$methodName];
		}

		try {
			$reflectionClass = $this->getReflectionClass($className);
			if ($methodName === '__construct') {
				$reflectionMethod = $reflectionClass->getConstructor();
			} else {
				$reflectionMethod = $reflectionClass->getMethod($methodName);
			}
			$this->reflectionMethods[$className][$methodName] = $reflectionMethod;
		} catch (ReflectionException $e) {
			throw new NotFoundException("Method $className::$methodName is not found");
		}

		return $reflectionMethod;
	}
674367
public function hasAnnotation($name, $methodName = NULL)
	{
		return NULL !== Annotations::hasAnnotation($name, $this, $methodName);
	}
799981
public function getMethod($methodName, $checkExtends = true)
    {
        $methodNameLower = strtolower($methodName);
        foreach ($this->methods as $name => $method) {
            if ($methodNameLower == $name) {
                return $method;
            }
        }

        if (!$checkExtends) {
            return false;
        }

        $extendsClassDefinition = $this->getExtendsClassDefinition();
        if ($extendsClassDefinition instanceof self) {
            if ($extendsClassDefinition->hasMethod($methodName)) {
                return $extendsClassDefinition->getMethod($methodName);
            }
        }

        return false;
    }
125150
public static function with( $with, $callback = null ) 
	{	
		if ( !is_array( $with ) )
		{
			$with = array( $with );
		}
		
		$settings = static::_model();
		
		$query = DB::select( $settings['table'] );
		
		// run the callback
		if ( !is_null( $callback ) )
		{
			call_user_func_array( $callback, array( &$query ) );
		}
		
		// alway group the result and fetch assoc
		$query->forward_key( $settings['primary_key'] );
		$query->fetch_arguments = array( 'assoc' );
		
		// get the main result set
		$results = static::assign( $query->run() );
		$singleton = false;
		
		if ( !is_array( $results ) )
		{
			$results = array( $results );
			$singleton = true;
		}
		
		$ref_object = reset( $results );
		
		// we have to sort the relationships to make sure that
		// select the relations in the right order.	
		asort( $with );
		
		foreach( $with as $relation => $callback )
		{
			if ( is_int( $relation ) && is_string( $callback ) )
			{
				$relation = $callback;
				$callback = null;
			}
			
			if ( strpos( $relation, '.' ) !== false )
			{	
				$relation_layers = explode( '.', $relation );
				
				$relation_name = array_pop( $relation_layers );
				
				$relation_collection = array();
				
				foreach( $results as $key => &$item )
				{
					$curr_item = $item;
					
					foreach( $relation_layers as $layer )
					{
						$curr_item = $curr_item->raw( $layer );
					}
					
					$relation_collection[] = $curr_item;
				}
				
				$ref_object = reset( $relation_collection );
				
				$relation_object = call_user_func( array( $ref_object, $relation_name ) );
				if ( $relation_object instanceof Model_Relation )
				{
					$relation_object->collection_assign( $relation_name, $relation_collection, $callback );
				}
			}
			else
			{
				$relation_object = call_user_func( array( $ref_object, $relation ) );
				if ( $relation_object instanceof Model_Relation )
				{
					$relation_object->collection_assign( $relation, $results, $callback );
				}
				
			}
		}
		
		if ( $singleton )
		{
			return reset( $results );
		}
		
		// and assign
		return $results;
	}
653369
public function with($withs)
    {
        if ( ! is_array($withs)) {
            $withs = func_get_args();
        }

        $this->withs = $withs;

        return $this;
    }
1259466
public function getMethod($methodName)
    {
        if ($methodName === '__construct') {
            return $this->getConstructor();
        }
        if (!isset($this->methods[$methodName])) {
            $this->methods[$methodName] = new ProxyMethod($this->fullOriginalClassName, $methodName);
            $this->methods[$methodName]->injectReflectionService($this->reflectionService);
        }
        return $this->methods[$methodName];
    }
1051485
private function parseMethodWithoutAnnotation(string $className, string $methodName)
    {
        $parser = new MethodWithoutAnnotationParser($this->annotationResource);
        $parser->parser($className, null, "", $methodName);
    }
1037827
private function getSnippetTemplate($pattern, $methodName, array $methodArguments)
    {
        return sprintf(
            self::$templateTemplate,
            str_replace('%', '%%', $pattern),
            $methodName,
            implode(', ', $methodArguments)
        );
    }
46591
protected function createServiceFile($name, $with_interface)
    {
        $dir_option = rtrim(str_replace('/', '\\', $this->getDirOption()), '/\\');
        $dir_option = $dir_option ? '\\' . $dir_option : '';
        $classname = $this->configureName('service', $name);

        if($with_interface === true) {
            $interface = trim($this->option('interface'));
            $interface = $this->configureName('repository', $interface ?: $name);

            $stub = str_replace(
                ['{{Namespace}}', '{{BaseServiceAbstractDirectory}}', '{{InterfaceDirectory}}', '{{InterfaceName}}', '{{ClassName}}'],
                [$this->getServiceDirectoryFromConfig() . $dir_option, $this->getServiceDirectoryFromConfig(),
                $this->getRepositoryDirectoryFromConfig() . $dir_option, $interface, $classname],
                $this->files->get($this->getServiceImplementsInterfaceStub())
            );
        } else {
            $stub = str_replace(
                ['{{Namespace}}', '{{BaseServiceAbstractDirectory}}', '{{ClassName}}'],
                [$this->getServiceDirectoryFromConfig() . $dir_option, $this->getServiceDirectoryFromConfig(), $classname],
                $this->files->get($this->getServiceStub())
            );
        }

        $this->files->put(base_path() . '/' . $this->getServiceDirectory() . $this->getDirOption() . $classname . '.php', $stub);
    }
1198846
private function parseActionMethod($methodName)
    {
        $actionTypeName = [
            'type' => null,
            'name' => null,
        ];

        preg_match('/(get|post|is|has|set|update|delete|remove)([A-Z].+)/', $methodName, $matches);

        if (isset($matches[1])) {
            // a couple of aliases
            $matches[1] == 'post' ? $matches[1] = 'POST' : false;
            $matches[1] == 'has' ? $matches[1] = 'POST' : false;
            $matches[1] == 'is' ? $matches[1] = 'POST' : false;
            $matches[1] == 'set' ? $matches[1] = 'POST' : false;
            $matches[1] == 'remove' ? $matches[1] = 'DELETE' : false;

            $actionTypeName['type'] = strtoupper($matches[1]);
        }

        if (isset($matches[2])) {
            $actionTypeName['name'] = lcfirst($matches[2]);
        }

        return $actionTypeName;
    }
52826
public function allWith($with, $limit = null)
    {
        if ($limit) {
            return $this->model->with($with)->limit($limit)->get();
        }

        return $this->model->with($with)->get();

    }