| 123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace common\logic\analyse;
- use common\traits\ErrorTrait;
- class BaseAnalyse{
- use ErrorTrait;
- public function getHandlers(){
- return [
- // CardAnalyse::class, // 名片分析处理
- ];
- }
- /**
- * 运行
- * @param $list
- * @return object|mixed
- */
- public function run($list)
- {
- try{
- $handlers = $this->getHandlers();
- if ($handlers) {
- foreach ($handlers as $key => $handler) {
- $item = $handler::analyse($list);
- if($item === false) throw new \Exception($handler::getStaticError());
- }
- }
- return true;
- }catch(\Exception $e){
- $this->setError($e->getMessage());
- return false;
- }
- }
- }
|