Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
30 / 30
100.00% covered (success)
100.00%
10 / 10
CRAP
100.00% covered (success)
100.00%
1 / 1
MaxfieldStatus
100.00% covered (success)
100.00%
30 / 30
100.00% covered (success)
100.00%
10 / 10
13
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 fromMaxfield
100.00% covered (success)
100.00%
21 / 21
100.00% covered (success)
100.00%
1 / 1
4
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getPath
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getStatus
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getLog
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isFilesFinished
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getFramesDirCount
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getMovieSize
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Type;
6
7use App\Entity\Maxfield;
8use App\Service\MaxFieldHelper;
9use Symfony\Component\Filesystem\Exception\FileNotFoundException;
10
11class MaxfieldStatus
12{
13    private int $id;
14
15    private string $name;
16
17    private string $path;
18
19    private string $status;
20
21    private bool $filesFinished;
22
23    private string $framesDirCount;
24
25    private string $movieSize;
26
27    private string $log;
28
29    public function __construct(private readonly MaxFieldHelper $maxFieldHelper) {}
30
31    public function fromMaxfield(Maxfield $maxfield): self
32    {
33        $this->id = (int)$maxfield->getId();
34        $this->name = (string)$maxfield->getName();
35        $this->path = (string)$maxfield->getPath();
36
37        try {
38            $this->log = (string)$this->maxFieldHelper->getLog($this->path);
39            if (str_contains($this->log, 'Total maxfield runtime')) {
40                $this->status = 'finished';
41            } elseif (str_contains(
42                $this->log,
43                'Traceback (most recent call last):'
44            )
45            ) {
46                $this->status = 'error';
47            } else {
48                $this->status = 'running';
49            }
50        } catch (FileNotFoundException) {
51            $this->status = 'X';
52        }
53
54        $this->filesFinished = $this->maxFieldHelper
55            ->filesFinished($this->path);
56
57        $this->framesDirCount = $this->maxFieldHelper
58            ->framesDirCount($this->path);
59
60        $this->movieSize = $this->maxFieldHelper
61            ->getMovieSize($this->path);
62
63        return $this;
64    }
65
66    public function getId(): int
67    {
68        return $this->id;
69    }
70
71    public function getName(): string
72    {
73        return $this->name;
74    }
75
76    public function getPath(): string
77    {
78        return $this->path;
79    }
80
81    public function getStatus(): string
82    {
83        return $this->status;
84    }
85
86    public function getLog(): string
87    {
88        return $this->log;
89    }
90
91    public function isFilesFinished(): bool
92    {
93        return $this->filesFinished;
94    }
95
96    public function getFramesDirCount(): string
97    {
98        return $this->framesDirCount;
99    }
100
101    public function getMovieSize(): string
102    {
103        return $this->movieSize;
104    }
105}