JaguarJack 94c430f491 update
2020-11-29 09:29:14 +08:00

88 lines
1.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
// +----------------------------------------------------------------------
// | 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
*/
public function psr4Autoload()
{
return $this->content()['autoload']['psr-4'];
}
/**
* require
*
* @time 2020年11月19日
* @return mixed
*/
public function requires()
{
return $this->content()['require'];
}
/**
* require dev
*
* @time 2020年11月19日
* @return mixed
*/
public function requireDev()
{
return $this->content()['require-dev'];
}
/**
* 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, 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()
{
return root_path() . 'composer.json';
}
}