88 lines
1.9 KiB
PHP
Raw Normal View History

2020-07-19 10:06:08 +08:00
<?php
2020-11-29 09:29:14 +08:00
declare(strict_types=1);
2020-07-19 10:06:08 +08:00
// +----------------------------------------------------------------------
// | CatchAdmin [Just Like ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
// +----------------------------------------------------------------------
// | Author: JaguarJack [ njphper@gmail.com ]
// +----------------------------------------------------------------------
namespace catcher\library;
use catcher\facade\FileSystem;
class Composer
{
/**
* psr4
*
* @time 2020年11月19日
* @return mixed
*/
2020-07-19 10:06:08 +08:00
public function psr4Autoload()
{
return $this->content()['autoload']['psr-4'];
2020-07-19 10:06:08 +08:00
}
/**
* require
*
* @time 2020年11月19日
* @return mixed
*/
2020-07-21 08:01:20 +08:00
public function requires()
{
return $this->content()['require'];
2020-07-21 08:01:20 +08:00
}
/**
* require dev
*
* @time 2020年11月19日
* @return mixed
*/
public function requireDev()
2020-07-19 10:06:08 +08:00
{
return $this->content()['require-dev'];
2020-07-19 10:06:08 +08:00
}
/**
* composer has package
*
* @time 2020年11月19日
* @param $name
* @return bool
*/
public function hasPackage($name)
{
$packages = array_merge($this->requires(), $this->requireDev());
2020-11-19 17:44:11 +08:00
return in_array($name, array_keys($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()
2020-07-19 10:06:08 +08:00
{
return root_path() . 'composer.json';
}
}