| Conditions | 4 | 
| Paths | 4 | 
| Total Lines | 31 | 
| Code Lines | 19 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php  | 
            ||
| 33 | public function resolve($object, array $args, $context, ResolveInfo $info)  | 
            ||
| 34 |     { | 
            ||
| 35 | $file = File::get()->byId($args['id']);  | 
            ||
| 36 |         if(!$file) { | 
            ||
| 37 | throw new \InvalidArgumentException(sprintf(  | 
            ||
| 38 | '%s#%s not found',  | 
            ||
| 39 | File::class,  | 
            ||
| 40 | $args['id']  | 
            ||
| 41 | ));  | 
            ||
| 42 | }  | 
            ||
| 43 | |||
| 44 |         if(!$file->isPublished()) { | 
            ||
| 45 | throw new \InvalidArgumentException(sprintf(  | 
            ||
| 46 | '%s#%s not published',  | 
            ||
| 47 | File::class,  | 
            ||
| 48 | $args['id']  | 
            ||
| 49 | ));  | 
            ||
| 50 | }  | 
            ||
| 51 | |||
| 52 |         if(!$file->canPublish($context['currentUser'])) { | 
            ||
| 53 | throw new \InvalidArgumentException(sprintf(  | 
            ||
| 54 | '%s#%s unpublish not allowed',  | 
            ||
| 55 | File::class,  | 
            ||
| 56 | $args['id']  | 
            ||
| 57 | ));  | 
            ||
| 58 | }  | 
            ||
| 59 | |||
| 60 | $file->doUnpublish();  | 
            ||
| 61 | |||
| 62 | return $args['id'];  | 
            ||
| 63 | }  | 
            ||
| 64 | }  | 
            ||
| 65 |