• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

podio-community / podio-php / 5242912328

pending completion
5242912328

push

github

web-flow
Merge pull request #228 from podio-community/90-non-static-podio-class

feat: isolated client class to allow for parallel usage + extension mocking

648 of 648 new or added lines in 66 files covered. (100.0%)

917 of 2108 relevant lines covered (43.5%)

24.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

56.67
/models/PodioFile.php
1
<?php
2
/**
3
 * @see https://developers.podio.com/doc/files
4
 */
5
class PodioFile extends PodioObject
6
{
7
    public function __construct(PodioClient $podio_client, $attributes = array())
8
    {
9
        parent::__construct($podio_client);
33✔
10
        $this->property('file_id', 'integer', array('id' => true));
33✔
11
        $this->property('link', 'string');
33✔
12
        $this->property('perma_link', 'string');
33✔
13
        $this->property('thumbnail_link', 'string');
33✔
14
        $this->property('hosted_by', 'string');
33✔
15
        $this->property('name', 'string');
33✔
16
        $this->property('description', 'string');
33✔
17
        $this->property('mimetype', 'string');
33✔
18
        $this->property('size', 'integer');
33✔
19
        $this->property('context', 'hash');
33✔
20
        $this->property('created_on', 'datetime');
33✔
21
        $this->property('rights', 'array');
33✔
22

23
        $this->has_one('created_by', 'ByLine');
33✔
24
        $this->has_one('created_via', 'Via');
33✔
25
        $this->has_many('replaces', 'File');
33✔
26

27
        $this->init($attributes);
33✔
28
    }
29

30
    private function get_download_link($size = null)
31
    {
32
        return $size ? ($this->link . '/' . $size) : $this->link;
×
33
    }
34

35
    /**
36
     * Returns the raw bytes of a file. Beware: This is not a static method.
37
     * It can only be used after you have a PodioFile object.
38
     */
39
    public function get_raw($size = null, PodioClient $podio_client)
40
    {
41
        return $podio_client->get($this->get_download_link($size), array(), array('file_download' => true))->body;
×
42
    }
43

44
    /**
45
     * Returns the raw bytes of a file. Beware: This is not a static method.
46
     * It can only be used after you have a PodioFile object.
47
     *
48
     * In contrast to get_raw this method does use minimal memory (the result is stored in php://temp)
49
     * @return resource pointing at start of body (use fseek($resource, 0) to get headers as well)
50
     */
51
    public function get_raw_as_resource($size = null, PodioClient $podio_client)
52
    {
53
        /** @noinspection PhpIncompatibleReturnTypeInspection */
54
        return $podio_client->get($this->get_download_link($size), array(), array('file_download' => true, 'return_raw_as_resource_only' => true));
×
55
    }
56

57
    /**
58
     * @see https://developers.podio.com/doc/files/upload-file-1004361
59
     */
60
    public static function upload($file_path, $file_name, PodioClient $podio_client)
61
    {
62
        return self::member($podio_client->post("/file/", array('filename' => $file_name, 'filepath' => $file_path), array('upload' => true, 'filesize' => filesize($file_path))), $podio_client);
×
63
    }
64

65
    /**
66
     * @see https://developers.podio.com/doc/files/get-file-22451
67
     */
68
    public static function get($file_id, PodioClient $podio_client)
69
    {
70
        return self::member($podio_client->get("/file/{$file_id}"), $podio_client);
×
71
    }
72

73
    /**
74
     * @see https://developers.podio.com/doc/files/get-files-on-app-22472
75
     */
76
    public static function get_for_app($app_id, $attributes = array(), PodioClient $podio_client)
77
    {
78
        return self::listing($podio_client->get("/file/app/{$app_id}/", $attributes), $podio_client);
×
79
    }
80

81
    /**
82
     * @see https://developers.podio.com/doc/files/get-files-on-space-22471
83
     */
84
    public static function get_for_space($space_id, $attributes = array(), PodioClient $podio_client)
85
    {
86
        return self::listing($podio_client->get("/file/space/{$space_id}/", $attributes), $podio_client);
×
87
    }
88

89
    /**
90
     * @see https://developers.podio.com/doc/files/attach-file-22518
91
     */
92
    public static function attach($file_id, $attributes = array(), $options = array(), PodioClient $podio_client)
93
    {
94
        $url = $podio_client->url_with_options("/file/{$file_id}/attach", $options);
×
95
        return $podio_client->post($url, $attributes);
×
96
    }
97

98
    /**
99
     * @see https://developers.podio.com/doc/files/replace-file-22450
100
     */
101
    public static function replace($file_id, $attributes = array(), PodioClient $podio_client)
102
    {
103
        return $podio_client->post("/file/{$file_id}/replace", $attributes);
×
104
    }
105

106
    /**
107
     * @see https://developers.podio.com/doc/files/copy-file-89977
108
     */
109
    public static function copy($file_id, PodioClient $podio_client)
110
    {
111
        return self::member($podio_client->post("/file/{$file_id}/copy"), $podio_client);
×
112
    }
113

114
    /**
115
     * @see https://developers.podio.com/doc/files/get-files-4497983
116
     */
117
    public static function get_all($attributes = array(), PodioClient $podio_client)
118
    {
119
        return self::listing($podio_client->get("/file/", $attributes), $podio_client);
×
120
    }
121

122
    /**
123
     * @see https://developers.podio.com/doc/files/delete-file-22453
124
     */
125
    public static function delete($file_id, PodioClient $podio_client)
126
    {
127
        return $podio_client->delete("/file/{$file_id}");
×
128
    }
129
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc