update:composer新增查找package方法

This commit is contained in:
JaguarJack 2020-11-19 17:31:04 +08:00
parent ecf0970ca4
commit e01790aa23

View File

@ -14,22 +14,72 @@ use catcher\facade\FileSystem;
class Composer
{
/**
* psr4
*
* @time 2020年11月19日
* @return mixed
*/
public function psr4Autoload()
{
return $this->composerContent()['autoload']['psr-4'];
return $this->content()['autoload']['psr-4'];
}
/**
* require
*
* @time 2020年11月19日
* @return mixed
*/
public function requires()
{
return $this->composerContent()['require'];
return $this->content()['require'];
}
protected function composerContent()
/**
* require dev
*
* @time 2020年11月19日
* @return mixed
*/
public function requireDev()
{
return \json_decode(FileSystem::get($this->composerJsonPath()), true);
return $this->content()['require-dev'];
}
protected function composerJsonPath()
/**
* composer has package
*
* @time 2020年11月19日
* @param $name
* @return bool
*/
public function hasPackage($name)
{
$packages = array_merge($this->requires(), $this->requireDev());
return in_array($name, $packages);
}
/**
* composer content
*
* @time 2020年11月19日
* @return mixed
*/
protected function content()
{
return \json_decode(FileSystem::sharedGet($this->path()), true);
}
/**
* composer path
*
* @time 2020年11月19日
* @return string
*/
protected function path()
{
return root_path() . 'composer.json';
}